// checks for file extension create by Gautam 8th may 2006
// this script checks file extensions and reurns the following
// 0 if it does not match with allowed extension
// 1 if it matches
// 2 if file name passed was blank

function showdetails(popupid)
{

}



function PdfCheck2()
{

	if(SaveForm.pdfs.value != "")
	{
		var retPDF = "yes";
		if((SaveForm.pdfs.value.match(".pdf") == null) && (SaveForm.pdfs.value.match(".PDF") == null) )
		{
			retPDF = "no";
		}
		if(retPDF == "no")
		{
			alert("Only the .pdf extension is allowed");
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
		return true;
	}
}




function is_ext_Valid(fileName,allowedExt)
{
	fileName = fileName.toLowerCase();
	if(fileName.length < 5)
	{
		return 2;
	}
	else
	{
		var extensions;
		extensions = allowedExt.toLowerCase();
		var strLen = fileName.length;
		strLen = strLen - 4;
		//get the extension of file
		var fileExt = fileName.substr(strLen,4);
		
		var extArr =extensions.split(",");
		var i;
		var status;
		for(i in extArr)
		{
			if(fileExt.match(extArr[i]))
			{	
				status = "ok";
				break;				
			}
		}
		
		if(status == "ok")
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}
}

function checkAll(formname)
{
	len=formname.elements.length;
	var i=0;
	for(i=0;i<len;i++)
	{
		if(formname.elements[i].type=='checkbox')
		{
			formname.elements[i].checked=1;
		}
	}
}

function uncheckAll(formname)
{
	len=formname.elements.length;
	var i=0;
	for(i=0;i<len;i++)
	{
		if(formname.elements[i].type=='checkbox')
		{
			formname.elements[i].checked=0;
		}
	}
}

function pageHandler(form)
{
	var URL = document.pagescounter.site.options[document.pagescounter.site.selectedIndex].value;
	window.location.href=URL;
}

function pageHandler(url)
{
	//var URL = document.pagescounter.site.options[document.pagescounter.site.selectedIndex].value;
	var URL=url;
	window.location.href=URL;
}

function countChecks1() {
	var abc = confirm("Do you really want to delete the record?");
	if(abc) {
	
	} else {
		return false;
	}
}
function docheck() {
	var abc = confirm("Do you really want to delete this record?");
	if(abc) {
	
	} else {
		event.returnValue=false;
	}
}

function validateData()
{
	var varRet;
	allowedExt = ".jpg,.gif,.png";
	varRet = is_ext_Valid(file1.value,allowedExt);
	if(varRet == 0)
	{
		alert("Only the following extensions are allowed" + allowedExt);
		return false;
	}
}

function selectImage(sURL,sSize)
	{
	divImg.innerHTML = "<img id='idImg' src='" + sURL + "' '" + sSize + "'>";
	}
	
	
	
function SubmitForm()
{
   if(SaveForm.file1.value == "")
	{
	alert("please select the image");
	return false;
	}
	
	  if(SaveForm.file1.value.length >0)
			 {
				var retJPG="";
				var retGIF="";
						
					
					if((SaveForm.file1.value.match(".jpg") == null) && (SaveForm.file1.value.match(".JPG") == null))
					{
					retJPG = "no";
					}
					if((SaveForm.file1.value.match(".gif") == null) && (SaveForm.file1.value.match(".GIF") == null))
					{
					retGIF = "no";		
					}
					if((retJPG == "no") && (retGIF == "no"))
					{
					alert("please use only .jpg or .gif images");
					SaveForm.file1.focus();
					
					return false;
					}				
				 }


}

function InsertHTML(frm)
{
	// Get the editor instance that we want to interact with.
	var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;

	// Check the active editing mode.
	if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
	{
	 
		// Insert the desired HTML.
		oEditor.InsertHtml(frm ) ;
		var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;

	
	}
	else
		alert( 'You must be on WYSIWYG mode!' ) ;
}


function InsertHTML2(frm)
{
	// Get the editor instance that we want to interact with.
	var oEditor = FCKeditorAPI.GetInstance('FCKeditor2') ;

	// Check the active editing mode.
	if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
	{
	 
		// Insert the desired HTML.
		oEditor.InsertHtml(frm ) ;
		var oEditor = FCKeditorAPI.GetInstance('FCKeditor2') ;

	
	}
	else
		alert( 'You must be on WYSIWYG mode!' ) ;
}
function InsertHTML3(frm)
{
	// Get the editor instance that we want to interact with.
	var oEditor = FCKeditorAPI.GetInstance('FCKeditor3') ;

	// Check the active editing mode.
	if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
 	{
	 
		// Insert the desired HTML.
		oEditor.InsertHtml(frm ) ;
		var oEditor = FCKeditorAPI.GetInstance('FCKeditor3') ;

	}
	else
		alert( 'You must be on WYSIWYG mode!' ) ;
}

function InsertHTML4(frm)
{
	// Get the editor instance that we want to interact with.
	var oEditor = FCKeditorAPI.GetInstance('FCKeditor4') ;

	// Check the active editing mode.
	if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
	{
	 
		// Insert the desired HTML.
		oEditor.InsertHtml(frm ) ;
		var oEditor = FCKeditorAPI.GetInstance('FCKeditor4') ;

	
	}
	else
		alert( 'You must be on WYSIWYG mode!' ) ;
}

//video check

function VideoCheck()
{
	
	
	if(SaveForm.file1.value != "")
	{
		var retAVI = "";
		var retMPEG = "";
		var retWMA = "";
		var retMOV = "";
		
		if((SaveForm.file1.value.match(".avi") == null) && (SaveForm.file1.value.match(".AVI") == null) )
		{
			retAVI = "no";
		}
		if((SaveForm.file1.value.match(".mpeg") == null) && (SaveForm.file1.value.match(".MPEG") == null) )
		{
			retMPEG = "no";		
		}
		if((SaveForm.file1.value.match(".wma") == null) && (SaveForm.file1.value.match(".WMA") == null) )
		{
			retWMA = "no";
		}
		if((SaveForm.file1.value.match(".mov") == null) && (SaveForm.file1.value.match(".MOV") == null))
		{
			retMOV = "no";
		}
		
		if((retAVI == "no") && (retMPEG == "no") && (retWMA == "no") && (retMOV == "no"))
		{
			alert("Only the following extension are allowed .avi, .mpeg, .wma, .mov");
			return false;
		}
	}
	
	
	if(SaveForm.file2.value != "")
	{
		var retAVI = "";
		var retMPEG = "";
		var retWMA = "";
		var retMOV = "";
		
		if((SaveForm.file2.value.match(".avi") == null) && (SaveForm.file2.value.match(".AVI") == null) )
		{
			retAVI = "no";
		}
		if((SaveForm.file2.value.match(".mpeg") == null) && (SaveForm.file2.value.match(".MPEG") == null) )
		{
			retMPEG = "no";		
		}
		if((SaveForm.file2.value.match(".wma") == null) && (SaveForm.file2.value.match(".WMA") == null) )
		{
			retWMA = "no";
		}
		if((SaveForm.file2.value.match(".mov") == null) && (SaveForm.file2.value.match(".MOV") == null))
		{
			retMOV = "no";
		}
		
		if((retAVI == "no") && (retMPEG == "no") && (retWMA == "no") && (retMOV == "no"))
		{
			alert("Only the following extension are allowed .avi, .mpeg, .wma, .mov");
			return false;
		}
	}
	
	
	
	
}
