// JavaScript Document
var hiddenTables="";
	function eFocus(etxt) {
		etxt.className="tboxOver";
	}
	
	function eBlur(etxt) {
		etxt.className="tbox";
	}

	function eTextAreaFocus(etxt) {
		etxt.className="tboxOver";
		etxt.style.overflow="auto";
	}
	
	function eTextAreaBlur(etxt) {
		etxt.className="tbox";
		etxt.style.overflow="hidden";
	}
	
	function getnbName(name)
		{
			if(name == 'News')
			{
				document.location.href = 'nbNewsPage.html';
			}
			else
			{
				document.location.href = 'nbgetFolderNamePage.html';
			}		
		}
	
	function ExpandCollapse(r, i, fld){
		document.getElementById("txtFolder").value = fld;
		
		if(navigator.appName.indexOf('Microsoft') == 0 )
		{
		    //For IE Browser
		    if ((document.getElementById(r).style.display =="") || (document.getElementById(r).style.display =="none")) {
			    document.getElementById(r).style.display ="block";
			    document.getElementById(i).src = "../images/icon_collapse_more.gif";
		    }
		    else{
			    document.getElementById(r).style.display ="none";
			    document.getElementById(i).src = "../images/icon_expand_more.gif";
		    }
		}
		else
		{
		    
		    if ((document.getElementById(r).style.display =="") || (document.getElementById(r).style.display =="none")) 
		    {   
			    document.getElementById(r).style.display = "table-row";
			    document.getElementById(i).src = "../images/icon_collapse_more.gif";
		    }
		    else{
			    document.getElementById(r).style.display = "none";
			    document.getElementById(i).src = "../images/icon_expand_more.gif";
		    }
		}
	}

	/*function getName(name){
		if(name == 'page'){
			document.location.href = 'tbgetPageNamePge.html';
		}
		else
		{
			document.location.href = 'tbgetFolderNamePge.html';
		}		
	}*/
	
	function popup(popurl,isCenter)
	{
		var myWidth = 750;
		var myHeight = 600;
		  if(window.screen)if(isCenter)if(isCenter=="true")
		  {
			var myLeft = (screen.width-myWidth)/2;
			var myTop = (screen.height-myHeight)/2;
		  }
		mywindow = window.open (popurl,"popwindow","toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1",+'width='+myWidth+',height='+myHeight);
	} 

	function ConfirmDelete() 
        {
		confirm("Do you want to Delete?");	
	}
	
	/*function ConfirmFolderDelete() 
        {
		confirm("Do you want to Delete this Folder?");	
	}*/
	function ConfirmPMFolderDelete() 
        {
		confirm("Do you want to Delete this Folder and its Projects?");	
	}
	function ConfirmCMFolderDelete() 
        {
		confirm("Do you want to Delete this Folder and its Jobs?");	
	}
	function ConfirmHTMLFolderDelete() 
        {
		confirm("Do you want to Delete this Folder and its HTML Component?");	
	}
	function ConfirmPHFolderDelete() 
        {
		confirm("Do you want to Delete this Folder and its albums?");	
	}
	
	
	function ConfirmPageDelete() 
        {
		confirm("Do you want to Delete this Page?");	
	}
	function ConfirmProjectDelete() 
        {
		confirm("Do you want to Delete the Project?");	
	}
	
	function ConfirmMenuDelete() 
        {
		confirm("Do you want to Delete this Menu?");	
	}
	function ConfirmNewsDelete() 
        {
		confirm("Do you want to Delete this News?");	
	}
	function ConfirmHTMLDelete() 
        {
		confirm("Do you want to Delete this HTML Component?");	
	}
	function ConfirmPhotoDelete() 
        {
		confirm("Do you want to Delete this Photo?");	
	}
	function ConfirmJobDelete() 
        {
		confirm("Do you want to Delete this Job?");	
	}
	function ConfirmPHGroupDelete() 
        {
		confirm("Do you want to Delete this Group ?");	
	}
	function ConfirmPHAlbumDelete() 
        {
		confirm("Do you want to Delete this Album ?");	
	}
	/*
	function Preview() 
        {
		 window.open("../PageBuilder/pbPageNamePge.html");
	}
	*/
    function getgbName(name){
		if(name == 'Album'){
			document.location.href = 'gbgetAlbumNamePage.html';
		}
		else if(name=='Group')
		{
			document.location.href = 'gbgetGroupNamePage.html';
		}		
		else
		{
			document.location.href = 'gbgetImageNamePage.html';
		}
	}
	
	function alertSize() {
		var myWidth = 0, myHeight = 0;
			if( typeof( window.innerWidth ) == 'number' ) 
			    {
			        //Non-IE
			        myWidth = window.innerWidth;
			        myHeight = window.innerHeight;
			    } 
			else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
			    {
			        //IE 6+ in 'standards compliant mode'
			        //myWidth = document.documentElement.clientWidth;
			        //myHeight = document.documentElement.clientHeight;
			        myWidth = screen.width;
			        myHeight = screen.height;
			    } 
			else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
			    {
			        //IE 4 compatible
			        myWidth = document.body.clientWidth;
			        myHeight = document.body.clientHeight;
			    }
			if((myWidth < 993) && (myHeight < 586))
			{
			    alert("1024x768 is the best resolution to view");
		    }
	}

	function brwsrView(popurl,isCenter,wid,hgt)
	{
		//alert('width'+wid + 'Height'+hgt);
		var myWidth = wid;
		var myHeight = hgt;
		  if(window.screen)if(isCenter)if(isCenter=="true")
		  {
			var myLeft = (screen.width-myWidth)/2;
			var myTop = (screen.height-myHeight)/2;
		  }
		mywindow = window.open (popurl,"popwindow","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes",+'width='+myWidth+',height='+myHeight);
		mywindow.resizeTo(myWidth,myHeight);
	}

	

	function getcamName(name){
		if(name == 'jobs'){
			document.location.href = 'camgetJob.html';
		}
		else
		{
			document.location.href = 'camgetFolderName.html';
		}		
	}
	
	function getpmName(name){
		if(name == 'project'){
			document.location.href = 'cmgetProject.html';
		}
		else
		{
			document.location.href = 'cmgetFolderName.html';
		}		
	}
	
	function getmenuName(name){
		if(name == 'page'){
			document.location.href = 'mbPageNamePge.html';
		}
		else
		{
			document.location.href = 'mbgetFolderNamePge.html';
		}		
	}
	
	function getnewsName(name){
		if(name == 'page'){
			document.location.href = 'nbNewsPage.html';
		}
		else
		{
			document.location.href = 'nbgetFolderNamePge.html';
		}		
	}
	
	function getpageName(name){
		if(name == 'page'){
			document.location.href = 'pbPageNamePge.html';
		}
		else
		{
			document.location.href = 'pbgetFolderNamePge.html';
		}		
	}
	
	function gettempName(name){
		if(name == 'page'){
			document.location.href = 'tbgetPageNamePge.html';
		}
		else
		{
			document.location.href = 'tbgetFolderNamePge.html';
		}		
	}
	
	
    function replace(string,text,by) {
		// Replaces text with by in string
		var strLength = string.length, txtLength = text.length;
		if ((strLength == 0) || (txtLength == 0)) return string;
		var i = string.indexOf(text);
		if ((!i) && (text != string.substring(0,txtLength))) return string;
		if (i == -1) return string;
		var newstr = string.substring(0,i) + by;
		if (i+txtLength < strLength)
		newstr += replace(string.substring(i+txtLength,strLength),text,by);
		return newstr;
	}
	//Test
	function dispControlIDs()
    {
        for(i=0;i<document.getElementsByTagName("input").length;i++)
            alert(document.getElementsByTagName("input").item(i).id);

    }

	//Validation
	function checkEmpty(ctrlid,alertMsg)
    {
        if(document.getElementById(ctrlid).value=="")
        {
            alert(alertMsg);
            document.getElementById(ctrlid).focus();
            return false;
        }
        return true;
    }
    function checkDropDown(ctrlid,alertMsg)
    {
        if(document.getElementById(ctrlid).value=="-1")
        {
            alert(alertMsg);
            document.getElementById(ctrlid).focus();
            return false;
        }
        return true;
    }
    function checkMinTextLength(ctrlid,minLength,minalertMsg)
    {
        if(document.getElementById(ctrlid).value.length < parseInt(minLength))
        {
            alert(minalertMsg);
            document.getElementById(ctrlid).focus();
            return false;
        }
        
        return true;
    }
    function checkMaxTextLength(ctrlid,maxLength,maxalertMsg)
    {
       
        if(document.getElementById(ctrlid).value.length > parseInt(maxLength))
        {
            alert(maxalertMsg);
            document.getElementById(ctrlid).focus();
            return false;
        }
        return true;
    }
    function checkTextLengthEquivalent(ctrlid,Length,alertMsg)
    {
        if(!(document.getElementById(ctrlid).value.length == parseInt(Length)))
        {
            alert(alertMsg);
            document.getElementById(ctrlid).focus();
            return false;
        }
        
        return true;
    }
    function IsNumericWithRange(field,fieldName, svlOtherSymbols, ivlLowerLimit,canBeEqualtoGivenLower, ivlUpperLimit,canBeEqualtoGivenUpper) {
   
	var valid = "0123456789" + svlOtherSymbols;
	var ok = "yes";
	var temp;
	var altMsg="";
	var field=document.getElementById(field);
	for (var i=0; i< field.value.length; i++) {
	    temp = "" + field.value.substring(i, i+1);
	 	if (valid.indexOf(temp) == "-1") ok = "no";
	}
	 
	if (ok == "no") {
	 	if (svlOtherSymbols == "") 
		{
			//alert ("Please enter Integers only");
			altMsg="Please enter Integers only";
			alert(altMsg);
		}
	 	else 
		{
			//alert ("It can be integer or it can contain symbols like " + svlOtherSymbols);
			altMsg=fieldName + " can be integer or it can contain symbols like " + svlOtherSymbols;
			alert(altMsg);
		}
	 	field.select();
		field.focus();
	 	return false;
	}
	
	if(canBeEqualtoGivenLower)
	{
	    if (field.value < ivlLowerLimit && field.value != ivlLowerLimit ) 
	    {
	        //alert ("It Should be greater than or equal to " + ivlLowerLimit + ".");
	        altMsg=fieldName + " should be greater than or equal to " + ivlLowerLimit;
		    alert(altMsg);
		    field.select();
		    field.focus();
		    return false; 
	    }
	}
	else
	{
	if (field.value < ivlLowerLimit) {
	        //alert ("It Should be greater than or equal to " + ivlLowerLimit + ".");
	        altMsg=fieldName + " should be greater than " + ivlLowerLimit;
		    alert(altMsg);
		    field.select();
		    field.focus();
		    return false; 
	    }
	
	}
	if(canBeEqualtoGivenUpper)
	{
	    if (field.value > ivlUpperLimit && field.value != ivlUpperLimit ) {
	        //alert ("It Should be greater than or equal to " + ivlLowerLimit + ".");
	        altMsg=fieldName + " should be lesser than or equal to " + ivlUpperLimit;
		    alert(altMsg);
		    field.select();
		    field.focus();
		    return false; 
	    }
	}
	else
	{
	if (field.value > ivlUpperLimit) {
	        //alert ("It Should be greater than or equal to " + ivlLowerLimit + ".");
	        altMsg=fieldName + " should be lesser than " + ivlUpperLimit;
		    alert(altMsg);
		    field.select();
		    field.focus();
		    return false; 
	    }
	}
	return true;
}
function setFocus(field)
{
    document.getElementById(field).focus();
}
function blockNonNumbers(obj, e, allowDecimal, allowNegative)
{
    window.status=''
	var key;
	var isCtrl = false;
	var keychar;
	var reg;
		
	if(window.event) {
		key = e.keyCode;
		isCtrl = window.event.ctrlKey
	}
	else if(e.which) {
		key = e.which;
		isCtrl = e.ctrlKey;
	}
	
	if (isNaN(key)) return true;
	
	keychar = String.fromCharCode(key);
	
	// check for backspace or delete, or if Ctrl was pressed
	if (key == 8 || isCtrl)
	{
		return true;
	}

	reg = /\d/;
	var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
	
	if(!(isFirstN || isFirstD || reg.test(keychar)))
	window.status='Numeric values only allowed';
	return isFirstN || isFirstD || reg.test(keychar);
}
function validateText(obj, e, isAlphaUpper, isAlphaLower, isNumeric, strSpecial) {
    window.status='';
	var value = obj.value;
	var key = e.keyCode;
	var stringLength = value.length;
	var isShift = false;
	var isCtrl = false;
	var validString = "";

	if(window.event) {
		key = e.keyCode;
		isShift = window.event.shiftKey;
		isCtrl = window.event.ctrlKey;
	} else if(e.which) {
		key = e.which;
		isShift = e.shiftKey;
		isCtrl = e.ctrlKey;
	}

	if (key == 8 || isCtrl) { return true; }

	if (isAlphaUpper) { validString += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; }
	if (isAlphaLower) { validString += "abcdefghijklmnopqrstuvwxyz"; }
	if (isNumeric) { validString += "0123456789"; }
	if (strSpecial != "") { validString += strSpecial; }

	//alert(key + " - " + String.fromCharCode(key) + " - " + stringLength);
	if (stringLength >= 0) {
		for (ivlLoop=0; ivlLoop<validString.length; ivlLoop++) {
			if (validString.indexOf(String.fromCharCode(key)) >= 0) {
				return true;
			}
		}
	}
    window.status='Invalid Key Pressed';
	return false;
}
function Add2Cart(ProductName,Price)
{
    var strLoc="";
    strLoc=window.location;
    alert(strLoc);
    strLoc=strLoc.toString();
    if(strLoc.indexOf("?")<0)
        strLoc+="?";
    strLoc+="&SHP="+ProductName+":"+Price+";";
    window.location=strLoc;
}
function encode(str2enc)
{
    var enCodedString="";
    var enCodeConstant=4;
    for(i=0;i<str2enc.length;i++)
       enCodedString+=String.fromCharCode(str2enc.charCodeAt(i)+enCodeConstant);
       
      return enCodedString;
}
function decode(str2Dec)
{
    var deCodedString="";
    var enCodeConstant=4;
    for(i=0;i<str2Dec.length;i++)
       deCodedString+=String.fromCharCode(str2Dec.charCodeAt(i)-enCodeConstant);
      return deCodedString;
}

    function hideTable(tblId)
    {
        //window.status=hiddenTables;
        if(hiddenTables.toString().indexOf(tblId+',')>-1)
        {
            document.getElementById(tblId).style.display="block";
            hiddenTables=hiddenTables.replace(tblId+',','');
            return true;
        }
        if(hiddenTables.toString().indexOf(tblId+',')<0)
        {
            document.getElementById(tblId).style.display="none";
            hiddenTables=hiddenTables+ tblId+',';
            return true;
        }
        
    }