// JavaScript Document

/* ------------Function to show Hover image effect----------------*/
var win=0;
function showLarge(imgPath)
{
if (win)
  {
   if(!win.closed) win.close();
  }
  
strPath="showLarge.asp?path="+imgPath;
win=open(strPath,"DPPOPEN" ,"toolbars=no,maximize=yes,scrollbars=yes,menubar=no,width=500,height=650,directories=no,resizable=1,screenX=0,screenY=0,left=0,top=0");
win.focus();
}
/* ----------------------------------------------------------*/


/*----------Function to open Uplaod Images window------------*/
var uplWin=0;
function uploadWindow(path,fileName,restrict_ext,safe_ext,totalBytes,createFolder,wWidth,wHeight,status,callFunc)
{
	if (uplWin)
  {
    if(!uplWin.closed) uplWin.close();
  }
 alert(fileName); 
strPath="../Admin/fileUpload/uploadForm.asp?destpath="+path+"&newFileName="+fileName+"&restrictExt="+restrict_ext+"&safeExt="+safe_ext+"&totalBytes="+totalBytes+"&callFunc="+callFunc;

 win=open(strPath,"uploadWindow" ,"toolbars=no,maximize=no,scrollbars=auto,menubar=no,width="+wWidth+",height="+wHeight+",directories=no,resizable=1,screenX=0,screenY=0,left=180,top=40");
//win=window.showModalDialog(strPath,'','dialogHeight: 400px; dialogWidth: 500px; center: Yes; help: No; resizable: No; status: No;');
//alert(uploadWindow.arguments[2].name)
//win.onUnload=alert("ddd") 
//uplWin.focus();
}

/*---------------------------------------------------------------*/


var win=0;
function showWindow(path,width,height)
{
if (win)
  {
    if(!win.closed) win.close();
  }
 strPath=path;
 win=open(strPath,"DPPOPEN" ,"toolbars=no,maximize=no,scrollbars=yes,menubar=no,width="+width+",height="+height+",directories=no,resizable=0,screenX=0,screenY=0,left=180,top=40");
 win.focus();
}


var editorWin=0;
function showEditorWindow(path,width,height)
{
if (editorWin)
  {
    if(!editorWin) editorWin.close();
  }
 strPath=path;
 editorWin=open(strPath,"DPPOPEN" ,"toolbars=no,maximize=no,minimize=no,scrollbars=no,menubar=no,width="+width+",height="+height+",directories=no,resizable=0,screenX=0,screenY=0,left=180,top=40");
//editorWin=window.showModelessDialog(strPath,'','dialogHeight: '+height+'px; dialogWidth: '+width+'px; center: Yes; help: No; resizable: No; status: No;');
// editorWin.onblur=function() {editorWin.focus()}
 editorWin.focus();
}


function showHidePanel(imgObj,panelId,imgPath)
{

if(document.getElementById==null){document.getElementById = document.all};
if(panelId.className=="unHide")
{
panelId.className="hide"
imgObj.src="../../images/cms/suttterOpen.gif"
}
else if(panelId.className=="hide")
{
panelId.className="unHide"
imgObj.src="../../images/cms/suttterClose.gif"
}

}

function showHideObject(elemId)
{
	
if(document.getElementById==null){document.getElementById = document.all};
var objId=document.getElementById(elemId);

/*if(objId.className=="unHide")
{objId.className="hide"}
else if(objId.className=="hide")
{objId.className="unHide"}*/


if(objId.style.visibility=="collapse")
{objId.style.visibility="visible"}
else if(objId.style.visibility=="visible" || objId.style.visibility=="")
{objId.style.visibility="hidden"}

//alert(objId.style.visibility="hidden")

}



function isCArray(MY_ARRAY)
{
if(MY_ARRAY.length>0)
return true;
else;
return false;
}

function submitForm(formObj,formAction,formMethod,Haction)
{ 
var formObje
formObje=document.getElementById(formObj)
//alert(formObje)
 formObje.Haction.value=Haction
 formObje.action=formAction;
 formObje.method=formMethod;
// alert(formObje.method)
 formObje.submit(); 
}

function chkSelectedChkBox(formObj,chkObj,msg)
{
var counter=0;
var msg1,msg2;
if (msg==undefined || msg=="")
{
	msg1="Are you sure, you want to delete";
	msg2="Rows Selected Please Select the Row(s) to delete";
}
else
{
 msg1=msg;
 msg2="Please Select the Row(s)";
}

if(isCArray(chkObj))
{
for(i=0;i<=(chkObj.length-1);i++)
{
 if(chkObj[i].checked==true)
 {counter=counter+1} 
}

}

else
{
if(chkObj.checked==true)
 {counter=counter+1} 
}

if(counter>0)
 {
  ans=confirm(msg1+" "+counter+" rows.")
  if(ans==true)
  {
   //alert("alldone");
  
   return true;
  }
 }
 else
 {
  alert(counter+" "+msg2);
  return false;

 }
 
//alert(chkObj.length)
}

function chkAllBoxes(formObj,chkName,title,obj)
{

var chkObj=formObj.elements[chkName]

if(chkObj.length>0)
{ 
 for(i=0 ; i<chkObj.length;i++)
 {
  if(chkObj[i].title==title)
  {chkObj[i].checked=obj.checked;}
 }
}
else
{
if(chkObj.title==title)
  {chkObj.checked=obj.checked;}
}

}


function gotoUrl(url,target)
{

window.location.href=url

}

function createObjAjax()
{
	var xmlHttpObj;
	try{
		// Firefox, Opera 8.0+, Safari
		xmlHttpObj=new XMLHttpRequest();
	}
	catch (e){
		// Internet Explorer
		try{
			xmlHttpObj=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e){
			try{
				xmlHttpObj=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){
				xmlHttpObj = false;
			}
		}
	}
	return xmlHttpObj;
}

function getData(url)
{
	var xmlHttp = createObjAjax();
	if (!xmlHttp) 
	 {
			alert("Your browser does not support AJAX!");
			return false;
	 }
	 else
	 {
		xmlHttp.onreadystatechange=function(){
			if(xmlHttp.readyState==4){
				retRes=xmlHttp.responseText;
				return retRes;
			}
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}

function getData(url,ctrlName)
{
	//alert(url);
	var xmlHttp = createObjAjax();
	if (!xmlHttp) 
	 {
			alert("Your browser does not support AJAX!");
			return false;
	 }
	 else
	 {
		xmlHttp.onreadystatechange=function(){
			if(xmlHttp.readyState==4){
				fillData(xmlHttp.responseText,ctrlName);
			}
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}
function fillData(data,ctrlName){

	var html="";
	var ctrlObj=document.getElementById(ctrlName);
	for(i=ctrlObj.options.length-1;i>=0;i--)
		ctrlObj.remove(i);


//	ctrlObj.innerHTML="";
	var row = data.split(";");
	for(i=0;i<row.length;i++){
		var col = row[i].split("|");
//		html = html + "<option value='"+ col[0] + "'>"+col[1]+"</option>\n";
		var optn = document.createElement("OPTION");
		optn.text = col[1];
		optn.value = col[0];
		ctrlObj.options.add(optn);
	}
	//ctrlObj.innerHTML=html;
}


function OnOffEffect(objName)
{
	
	var obj = document.getElementsByName(objName);
	for(i=0;i<obj.length;i++)
	{
		var sStyle = obj[i].style.display;
		if(sStyle=='table-row' || sStyle=='block')
		{
			obj[i].style.display='none';
		}
		else
		{
			/*
			alert('b');			
			if (navigator.appName == "Microsoft Internet Explorer") 
				obj[i].style.display="block";
			else
				obj[i].style.display='table-row';
			*/
			try 
			{
				obj[i].style.display='table-row';
			} 
			catch(e) 
			{
				obj[i].style.display='block';
			}
	
			
		}
	}			
	return true;
}

function Clickheretoprint(contentId)
{ 
	var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
	disp_setting+="scrollbars=yes,width=700, height=400, left=100, top=25"; 
	//alert(contentId);
	var bb = document.getElementById(contentId);
	//alert(bb.innerHTML);
	var content_vlue= bb.innerHTML; 
	var docprint=window.open("exportReports/PRINTnEXPORT.asp","",disp_setting); 
}

