/* Image Caching */
var pic1 = new Image(111,26);
pic1.src = WWWROOT + '/images/load_bg.gif';

var pic2 = new Image(17,10);
pic2.src = WWWROOT + '/common/sdmenu/linkarrow.gif';

var pic3 = new Image(37,32);
pic3.src = WWWROOT + '/workshop/images/row_bg_new.gif';

var pic4 = new Image(150,17);
pic4.src = WWWROOT + '/workshop/images/row_bg_new2.gif';

var pic5 = new Image(132,25);
pic5.src = WWWROOT + '/workshop/images/bg_loading.gif';
/* Image Caching */

function loadingapp()
{
	
	if(document.getElementById("transLoading"))	
		document.getElementById("transLoading").style.display = 'none';
}
var lastColor;
function trMouseOver(obj) 
{
	lastColor = obj.style.backgroundImage;
	obj.style.backgroundImage="url("+WWWROOT+"/admin/images/row_bg_new.gif)";
//	obj.style.backgroundImage = WWWROOT+'/workshop/images/bg_heading.gif';
}
function trMouseOut(obj) 
{
	obj.style.backgroundImage = lastColor;
}


function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}
function isValidEmail(el)
{        
		var str=el;
		var filter=/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;

		var testresults;
		if (filter.test(str))
				testresults=true;
		else 
				testresults=false;
		return (testresults);
}

function isHaveSpecialChars(str)
{        
	 var iChars = "!@#$%^&*()+=[]\\\';,/{}|\":<>?";
	  for (var i = 0; i < str.length; i++) 
	  {
  		if (iChars.indexOf(str.charAt(i)) != -1)
  			return true;
		else
			return false;
 	 }
}

function CompareDates(txtAuctionSDate, txtAuctionEDate, Caption1, Caption2)
 {
	 //alert(txtAuctionSDate.value.length);
	//alert(txtAuctionEDate.value.length);                
	//return false;
 if(txtAuctionSDate.length!=0 && txtAuctionEDate.length!=0 )
	{
	  var StartDate = txtAuctionSDate;
	  var EndDate = txtAuctionEDate;
	 
	  var arrStart = StartDate.split("-");
	  var arrEnd = EndDate.split("-");          
	  
  if(parseInt(arrEnd[2])<parseInt(arrStart[2]))
		{
		 //alert( Caption1 + ' should be less than or equal to ' + Caption2 + '.' );
		  return false; 
		}
  else if(parseInt(arrEnd[2])==parseInt(arrStart[2]))
	{
		if(parseInt(arrEnd[0])<parseInt(arrStart[0]))
		{
				 //alert( Caption1 + '  should be less than or equal to ' + Caption2 + '.' );
				 return false;
		}
	   else if(parseInt(arrEnd[0])==parseInt(arrStart[0]))        
		{
			  if(arrEnd[1]<=arrStart[1])
				{
				//alert( Caption1 + ' should be less than or equal to ' + Caption2 + '.' );
				return false;
				}
			  else return true;                        
		 }
		 else return true;
	}		
   else return true;                        
 }
 else
 {
	return true;
 } 
} 

//This function does not allow equality of two dates also.
//For Used In These Fils: ListNewsletter.php.
function CompareDatesEquality(txtAuctionSDate, txtAuctionEDate, Caption1, Caption2)
 {
 //alert(txtAuctionSDate.value.length);
//alert(txtAuctionEDate.value.length);                
//return false;
 
 if(txtAuctionSDate.length!=0 && txtAuctionEDate.length!=0 )
	{
	  var StartDate = txtAuctionSDate;
	  var EndDate = txtAuctionEDate;
	 
	  var arrStart = StartDate.split("-");
	  var arrEnd = EndDate.split("-");          
	  
  if(arrEnd[2]<arrStart[2])
	{
	// alert('You must select a future date.');
	  return false; 
	}
  else if(arrEnd[2]==arrStart[2]) 
	{
		if(parseInt(arrEnd[0])<parseInt(arrStart[0]))
		{
				// alert('You must select a future date.');
				 return false;
		}
	   else if(parseInt(arrEnd[0])==parseInt(arrStart[0]))        
		{
			  if(arrEnd[1]<=arrStart[1])
				{
				//alert('You must select a future date.');
				return false;
				}
			    else return true;
		 }
		 else return true;
	}		
   else return true;                        
 }
 else
 {
	return true;
 } 
} 


	function IsEmpty(aTextField) {

		var regexp = /^(\s)*$/

		if(regexp.test(aTextField.value)){
			return "YES";

		}else{
			return "NO";
		}

	}//IsEmpty
function TestFileType( fileName, fileTypes )
{
	if (!fileName)
		return 1;
	
	dots = fileName.split(".")
	//get the part AFTER the LAST period.
	fileType = "." + dots[dots.length-1];
	
	if(fileTypes.join(".").indexOf(fileType) == -1)
	{
		//alert("Please upload only files with extension: \n\n" + (fileTypes.join(" .")) + "\n\nPlease select a new file and try again.");
		alert("Please upload only file with extension: \n(" + (fileTypes.join(" ."))+")" );
		return 0;
	}
	else
	{
		return 1;
	}
	return 0;

}

	function isValidEmail(el)
	{        
			var str=el;
			var filter=/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;

			var testresults;
			if (filter.test(str))
					testresults=true;
			else 
					testresults=false;
			return (testresults);
	}


	function getWpopup(pick)
	{
		
		var varwch=0;
		var varwcw=0;
		var hdnIds=document.getElementById("hdndocIds").value;

		if(document.frmPostCode.rdoWChoice[3].checked==true)
		{
			if(document.getElementById("txtWCHeight").value=="")
			{
				alert("Please enter height.")
				document.getElementById("txtWCHeight").focus();
				return false;
			}

			if(isNaN(document.getElementById("txtWCHeight").value))
			{
				alert("Please enter height in numeric values.")
				document.getElementById("txtWCHeight").focus();
				return false;
			}

			if(document.getElementById("txtWCWidth").value=="")
			{
				alert("Please enter width.")
				document.getElementById("txtWCWidth").focus();
				return false;
			}

			if(isNaN(document.getElementById("txtWCWidth").value))
			{
				alert("Please enter width in numeric values.")
				document.getElementById("txtWCWidth").focus();
				return false;
			}
			varwch=document.getElementById("txtWCHeight").value;
			varwcw=document.getElementById("txtWCWidth").value;
		}
		else if(document.frmPostCode.rdoWChoice[2].checked==true)
		{
			if(document.frmPostCode.rdoWCType[1].checked==true)
			{
				varwch=600;
				varwcw=170;	
			}
			else
			{
				varwch=170;
				varwcw=600;	
			}
		}
		else if(document.frmPostCode.rdoWChoice[1].checked==true)
		{
			if(document.frmPostCode.rdoWCType[1].checked==true)
			{
				varwch=500;
				varwcw=170;	
			}
			else
			{
				varwch=170;
				varwcw=500;	
			}
		}
		else
		{
			if(document.frmPostCode.rdoWCType[1].checked==true)
			{
				varwch=400;
				varwcw=170;	
			}
			else
			{
				varwch=170;
				varwcw=400;	
			}
		}
		
		var passheight=varwch;
		var passwidth=varwcw;
		
		if(passwidth>=passheight)
		{
			  strEmbedSRC = '<object classid="clsid:d27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" height="'+passheight+'" width="'+passwidth+'" align="top">';
			  strEmbedSRC+='<param name="movie" value="'+wwwroot+'/api/Horizontal_Widget.swf?docIds='+hdnIds+'"/>';
			  strEmbedSRC+='<param name="quality" value="high"/>'; 
			  strEmbedSRC+='<param name="allowFullScreen" value="true" />';
			  strEmbedSRC+='<param name="allowScriptAccess" value="always"/>';
		      strEmbedSRC+='<param name="wmode" value="transparent" />';
			  strEmbedSRC+='<param name="bgcolor" value="#cccccccc">';
			  strEmbedSRC+='<param name="scale" value="" />';
			  strEmbedSRC+='<embed src="'+wwwroot+'/api/Horizontal_Widget.swf?docIds='+hdnIds+'" height="'+passheight+'" width="'+passwidth+'" align="top" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" bgcolor="#cccccc" scale="">';
			  strEmbedSRC+='</embed>';
			  strEmbedSRC+='</object>';


		}
		else
		{

			  strEmbedSRC = '<object classid="clsid:d27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" height="'+passheight+'" width="'+passwidth+'" align="top">';
			  strEmbedSRC+='<param name="movie" value="'+wwwroot+'/api/Vertical_Widget.swf?docIds='+hdnIds+'"/>';
			  strEmbedSRC+='<param name="quality" value="high"/>'; 
			  strEmbedSRC+='<param name="allowFullScreen" value="true" />';
			  strEmbedSRC+='<param name="allowScriptAccess" value="always"/>';
		      strEmbedSRC+='<param name="wmode" value="transparent" />';
			  strEmbedSRC+='<param name="bgcolor" value="#cccccccc">';
			  strEmbedSRC+='<param name="scale" value="" />';
			  strEmbedSRC+='<embed src="'+wwwroot+'/api/Vertical_Widget.swf?docIds='+hdnIds+'" height="'+passheight+'" width="'+passwidth+'" align="top" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" bgcolor="#cccccc" scale="">';
			  strEmbedSRC+='</embed>';
			  strEmbedSRC+='</object>';

		}

		if(pick==false)
		{
			document.getElementById("PostForm").style.display='none';
			document.getElementById("wGCode").style.display='';
			document.getElementById("TEXTAREA_ID").value=strEmbedSRC;
		}
		else
		{
			document.getElementById("TEXTAREA_ID").value=strEmbedSRC;

			window.open(wwwroot+"/api/viewsample.html",null, "height=250,width=600,status=yes,toolbar=yes,resizable=1")
		}

		

	}

	function getrdoWChoice(wctype)
	{
		if(wctype=="4")
		{
			document.getElementById("txtWCHeight").disabled=false;
			document.getElementById("txtWCWidth").disabled=false;
		}
		else
		{
			document.getElementById("txtWCHeight").disabled=true;
			document.getElementById("txtWCWidth").disabled=true;
			document.getElementById("txtWCHeight").value="";
			document.getElementById("txtWCWidth").value="";
		}

	}

	function ShowPreviewSample()
	{
		window.open(wwwroot+"/api/viewsample.html",null, "height=200,width=500,status=yes,toolbar=yes,resizable=1")
	}

	function ShowDiv(varids,ieheight)
	{
	 var elList;

  //DefaultLoad();
	if(!ieheight)
	{
		ieheight=250;
	}


  document.getElementById("sample1").style.display='';
  document.getElementById("hdndocIds").value=varids
  // Initialize window control object.


  winCtrl.maxzIndex                        =   0;
  winCtrl.resizeCornerSize                 =  16;
  winCtrl.minimizedTextWidth               = 100;
  winCtrl.inactiveFrameBackgroundColor     = "#c0c0c0";
  winCtrl.inactiveFrameBorderColor         = "#f0f0f0 #505050 #404040 #e0e0e0";
  winCtrl.inactiveTitleBarColor            = "#808080";
  winCtrl.inactiveTitleTextColor           = "#c0c0c0";
  winCtrl.inactiveClientAreaBorderColor    = "#404040 #e0e0e0 #f0f0f0 #505050";
  winCtrl.inactiveClientAreaScrollbarColor = "";
  winCtrl.inMoveDrag                       = false;
  winCtrl.inResizeDrag                     = false;

  // Initialize windows and build list.

  elList = document.getElementsByTagName("DIV");
  for (var i = 0; i < elList.length; i++)
    if (elList[i].className == "window")
      winList[elList[i].id] = new Window(elList[i]);



	if(navigator.appName == "Microsoft Internet Explorer") 
	{
		screenY = document.body.offsetHeight;
		screenX = window.screen.availWidth;
	}
	else 
	{
		screenY = window.outerHeight;
		screenX = window.outerWidth;
	}
	
	if(navigator.appName == "Microsoft Internet Explorer") 
	{
		leftprop = document.body.scrollLeft + ((screenX - 400) / 2);
		topprop = document.body.scrollTop + ieheight;
	}
	else 
	{
		leftprop = pageXOffset  + ((screenX - 400) / 2);
		topprop = parseInt(pageYOffset + 80,10);
	}

	windowLeft = leftprop;
	windowTop = topprop;


	document.getElementById("sample1").style.left = windowLeft+"px";
	document.getElementById("sample1").style.top = windowTop+"px";
	if(winList['sample1']) 
		winList['sample1'].open(); 

	return false;
}


	function ShowFriendsDiv()
	{
	 var elList;

  //DefaultLoad();
	ieheight=150;


  document.getElementById("sample2").style.display='';
  // Initialize window control object.


  winCtrl.maxzIndex                        =   0;
  winCtrl.resizeCornerSize                 =  16;
  winCtrl.minimizedTextWidth               = 100;
  winCtrl.inactiveFrameBackgroundColor     = "#c0c0c0";
  winCtrl.inactiveFrameBorderColor         = "#f0f0f0 #505050 #404040 #e0e0e0";
  winCtrl.inactiveTitleBarColor            = "#808080";
  winCtrl.inactiveTitleTextColor           = "#c0c0c0";
  winCtrl.inactiveClientAreaBorderColor    = "#404040 #e0e0e0 #f0f0f0 #505050";
  winCtrl.inactiveClientAreaScrollbarColor = "";
  winCtrl.inMoveDrag                       = false;
  winCtrl.inResizeDrag                     = false;

  // Initialize windows and build list.

  elList = document.getElementsByTagName("DIV");
  for (var i = 0; i < elList.length; i++)
    if (elList[i].className == "window")
      winList[elList[i].id] = new Window(elList[i]);



	if(navigator.appName == "Microsoft Internet Explorer") 
	{
		screenY = document.body.offsetHeight;
		screenX = window.screen.availWidth;
	}
	else 
	{
		screenY = window.outerHeight;
		screenX = window.outerWidth;
	}
	
	if(navigator.appName == "Microsoft Internet Explorer") 
	{
		leftprop = document.body.scrollLeft + ((screenX - 400) / 2);
		topprop = document.body.scrollTop + ieheight;
	}
	else 
	{
		leftprop = pageXOffset  + ((screenX - 400) / 2);
		topprop = parseInt(pageYOffset + 80,10);
	}

	windowLeft = leftprop;
	windowTop = topprop;


	document.getElementById("sample2").style.left = windowLeft+"px";
	document.getElementById("sample2").style.top = windowTop+"px";
	if(winList['sample2']) 
		winList['sample2'].open(); 

	return false;
}

function ShowAddtoDiv(eheight)
{
	 var elList;

  //DefaultLoad();

	if(eheight=='')
		ieheight=550;
	else
		ieheight=eheight;


  document.getElementById("sample3").style.display='';
  // Initialize window control object.


  winCtrl.maxzIndex                        =   0;
  winCtrl.resizeCornerSize                 =  16;
  winCtrl.minimizedTextWidth               = 100;
  winCtrl.inactiveFrameBackgroundColor     = "#c0c0c0";
  winCtrl.inactiveFrameBorderColor         = "#f0f0f0 #505050 #404040 #e0e0e0";
  winCtrl.inactiveTitleBarColor            = "#808080";
  winCtrl.inactiveTitleTextColor           = "#c0c0c0";
  winCtrl.inactiveClientAreaBorderColor    = "#404040 #e0e0e0 #f0f0f0 #505050";
  winCtrl.inactiveClientAreaScrollbarColor = "";
  winCtrl.inMoveDrag                       = false;
  winCtrl.inResizeDrag                     = false;

  // Initialize windows and build list.

  elList = document.getElementsByTagName("DIV");
  for (var i = 0; i < elList.length; i++)
    if (elList[i].className == "window")
      winList[elList[i].id] = new Window(elList[i]);



	if(navigator.appName == "Microsoft Internet Explorer") 
	{
		screenY = document.body.offsetHeight;
		screenX = window.screen.availWidth;
	}
	else 
	{
		screenY = window.outerHeight;
		screenX = window.outerWidth;
	}
	
	if(navigator.appName == "Microsoft Internet Explorer") 
	{
		leftprop = document.body.scrollLeft + ((screenX - 400) / 2);
		topprop = document.body.scrollTop + ieheight;
	}
	else 
	{
		leftprop = pageXOffset  + ((screenX - 400) / 2);
		topprop = parseInt(pageYOffset + 80,10);
	}

	windowLeft = leftprop;
	windowTop = topprop;


	document.getElementById("sample3").style.left = windowLeft+"px";
	document.getElementById("sample3").style.top = windowTop+"px";
	if(winList['sample3']) 
		winList['sample3'].open(); 


	return false;
} 

function hideMessageDiv()
{
	document.getElementById("ShowMessage").style.display = 'none';	
}
function toggleDiv(flag)
{
	
	if(flag==1 && document.getElementById('div1').style.display=='none')
	{
		document.getElementById('div1').style.display='block'
	}
	else if(document.getElementById('div1').style.display=='block')
	{
		document.getElementById('div1').style.display='none'
	}
}
function isValidZipOld(Zip)
{        
	var Zip = new String(Zip);                
	return /^[(0-9][0-9-]*$/.test(Zip);
}	

function isValidZip(zipcode)
{
		if (zipcode!=""){

		var numericExpression = /^[0-9a-zA-Z\+\-\s]{2,}$/;
		if(zipcode.match(numericExpression)){
			 return true;
		}else{
			return false;
		}		 
		 
		 
	}


}


function setCookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
function isValidUrl(url)
{        
        var pattern = /http:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/;
        return pattern.test(url);
}
function checkURL(value) {
	
var urlregex = new RegExp("^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([0-9A-Za-z]+\.)");
if(urlregex.test(value))
{
return(true);
}
return(false);
}
function GetNewImage(a,b)
{
var StrPattern=genPattern(6);
b.value=StrPattern;
a.src=WWWROOT+"/common/human_detector/doimg1.php?qtext="+StrPattern+"&q="+Math.floor((4 - 1 + 1) * Math.random() + 1);
}
 function charFromCharCode (charCode) {
   if(charCode<3)
   { charCode=123-charCode;}
   else if(charCode>3 && charCode<6)
   { charCode=58-charCode; }
   else
   { charCode=78-charCode; }
    return unescape('%' + charCode.toString(16));
  }
  
 
function genPattern(pintLen)
{
    var strRet = "";
    var iCntr  = 0;
    var rndNo  = 0;

    for (iCntr = 0; iCntr < pintLen; iCntr++)
    {
        rndNo = Math.floor((4 - 1 + 1) * Math.random() + 1);
		strRet +=charFromCharCode(rndNo);
    }
	return strRet;
}

function rnd()
{
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
rnd.seed = (rnd.seed*9301+49297) % 233280;
return rnd.seed/(233280.0);
}

function rand(number)
{
return Math.ceil(rnd()*number);
}


function ShowCodeDiv()
{
	

		if(document.getElementById('DivTagContent').style.display=='block')
			document.getElementById('DivTagContent').style.display='none';
		else
		if(document.getElementById('DivTagContent').style.display=='none')
			document.getElementById('DivTagContent').style.display='block';
}//sendRequest
function closeDiv()
{
		document.getElementById('DivTagContent').style.display='none';
}//sendRequest

function ClearErrorMessage(val, DivId, ObjectName, Validate, pstrClassName)
{
	value = document.getElementById(ObjectName).value;
	if(trim(val)!='')
	{
		document.getElementById(DivId).style.display = 'none';
		if(document.getElementById(ObjectName) && pstrClassName!=1)
		{
			document.getElementById(ObjectName).className="form-input";
		}
	}
	if(Validate=='email')
	 {
		 if(!isValidEmail(value))
		 {
			document.getElementById(DivId).style.display = '';
			document.getElementById(ObjectName).className="form-input-req"
			document.getElementById(DivId).innerHTML = 'Email Address must be in following format: example@example.com !';
		 }
		 
	 }
	if(Validate=='confirmemail')
	 {
		 if(!isValidEmail(value))
		 {
			document.getElementById(DivId).style.display = '';
			document.getElementById(ObjectName).className="form-input-req"
			document.getElementById(DivId).innerHTML = 'Email Address must be in following format: example@example.com !';
		 }
		 if(trim(value) != trim(document.getElementById('txtEmail').value))
		 {
			document.getElementById(DivId).style.display = '';
			document.getElementById(ObjectName).className="form-input-req"
			document.getElementById(DivId).innerHTML = 'Email and confirm email should be same !';
		 }
		 
	 }
	if(Validate=='password')
	 {
		 if(value.length<6)
		 {
			document.getElementById(DivId).style.display = '';
			document.getElementById(ObjectName).className="form-input-req"
			document.getElementById(DivId).innerHTML = 'Minimum and Maximum length for Password is 6 and 20 !';
		 }
	 }
	if(Validate=='confirmpassword')
	 {
		 if(value.length<6)
		 {
			document.getElementById(DivId).style.display = '';
			document.getElementById(ObjectName).className="form-input-req"
			document.getElementById(DivId).innerHTML = 'Minimum and Maximum length for Password is 6 and 20 !';
		 }
		 if(trim(value) != trim(document.getElementById('txtPassword').value))
		 {
			document.getElementById(DivId).style.display = '';
			document.getElementById(ObjectName).className="form-input-req"
			document.getElementById(DivId).innerHTML = 'Password and confirm password should be same !';
		 }
		 
	 }
}	

function ClearUrlErrorMessage(val,DivId,ObjectName)
{
	value = document.getElementById(ObjectName).value;
	if(trim(val)!='')
	{
		 if(!isValidUrl(value))
		 {
			document.getElementById(DivId).style.display = '';
			document.getElementById(ObjectName).className="form-input-req"
			document.getElementById(DivId).innerHTML = 'Please enter valid url !';
		 }
		 
		 else
		 {
			 	document.getElementById(DivId).style.display = 'none';
		
				if(document.getElementById(ObjectName))
				{
					document.getElementById(ObjectName).className="form-input";
				}

		 }
		
	}
	else
	{
		document.getElementById(DivId).style.display = 'none';
		
		if(document.getElementById(ObjectName))
		{
			document.getElementById(ObjectName).className="form-input";
		}

	}
	
}
function ClearZipErrorMessage(val,DivId,ObjectName)
{
	value = document.getElementById(ObjectName).value;
	if(trim(val)!='')
	{
		if(value.length>5 && value.length <=10)
		{
			 if(!isValidZip(value))
			 {
				document.getElementById(DivId).style.display = '';
				document.getElementById(ObjectName).className="form-input-req"
				document.getElementById(DivId).innerHTML = 'Zipcode can accept only numeric values, characters, space, + & - !';
			 }
			 else
			 {
					document.getElementById(DivId).style.display = 'none';
			
					if(document.getElementById(ObjectName))
					{
						document.getElementById(ObjectName).className="form-input";
					}
	
			 }
		}
		else
		{
				document.getElementById(DivId).style.display = '';
				document.getElementById(ObjectName).className="form-input-req"
				document.getElementById(DivId).innerHTML = 'Minimum and Maximum length for zipcode is 5 and 10 !';
		}
		
	}
	else
	{
		document.getElementById(DivId).style.display = 'none';
		
		if(document.getElementById(ObjectName))
		{
			document.getElementById(ObjectName).className="form-input";
		}

	}
	
}
function ClearTextAreaErrorMessage(val,DivId,ObjectName,className)
{
	if(trim(val)!='')
	{
		document.getElementById(DivId).style.display = 'none';
		
		if(document.getElementById(ObjectName))
		{
			if(className!="")
				document.getElementById(ObjectName).className=className;
			else
				document.getElementById(ObjectName).className="text-area350";
		}
		
	}
}
function ClearCheckErrorMessage(val,DivId,ObjectName)
{
	if(document.getElementById(ObjectName).checked==true)
	{
		document.getElementById(DivId).style.display = 'none';
	}
}
function ClearDropDownErrorMessage(val,DivId,ObjectName)
{
	if(trim(val)!='')
	{
		document.getElementById(DivId).style.display = 'none';
		
	}
}

function isDeleteRecord()
{
var agree=confirm("Are you sure you want to delete the selected item?");
if (agree)
	return true ;
else
	return false ;
}

function isCharPost(el,mode)
{
	
	var valid=1;
	elValue = el.value;
	if(el.value.length==0) return true;
	if(mode==0){var regex = new RegExp(/^[a-zA-Z]+$/); valid=regex.test(el.value)}
	if(mode==1){var regex = new RegExp(/^[a-zA-Z0-9\s]+$/); valid=regex.test(el.value)}
	if(mode==2){var regex = new RegExp(/^[a-zA-Z0-9.,_\-\s]+$/); valid=regex.test(el.value)}
	if(mode==3){var regex = new RegExp(/^[a-zA-Z0-9.,_\-\s]+$/); valid=regex.test(el.value)}
	if(mode==4){var regex = new RegExp(/^[a-zA-Z][a-zA-Z0-9._ \-]+$/); valid=regex.test(el.value)}
	if(mode==5){var regex = new RegExp(/^[0-9]+$/); valid=regex.test(el.value)}
	if(mode==6){var regex = new RegExp(/^[a-zA-Z][a-zA-Z0-9!._ \s\-]+$/); valid=regex.test(el.value)}
	if(mode==7){var regex = new RegExp(/^[0-9,.]+$/); valid=regex.test(el.value)}
	if(mode==8){var regex = new RegExp(/^[a-zA-Z][a-zA-Z0-9!?._ \-]+$/); valid=regex.test(el.value)}
	if(mode==9){var regex = new RegExp(/^[0-9]?[0-9,]+$/); valid=regex.test(el.value)}
	
	if(!valid) 
	{
		return true;
	}
	else return false;
}
//paging code starts here

function GetPage(entityId,entityType,pge, rec, type,ord,sby,pagetype)
{
 	document.getElementById('transLoading').style.display='';
	if(document.getElementById('id'))
		var id = document.getElementById('id').value;
	else
		var id = '';
	if(document.getElementById('txtSearch'))
	{
								   
		if(document.getElementById('txtSearch').value!="")
			txtSearch = document.getElementById('txtSearch').value;
		else
			txtSearch = '';
	}
	else
		txtSearch = '';

	myRand=parseInt(Math.random()*99999999);
	strURL = WWWROOT+"/post/PostPaging.php?page=comments&rand="+myRand+"&entityId="+entityId+"&entityType="+entityType+"&_pge="+pge+"&_rec="+rec+"&_ord="+ord+"&_sby="+sby+"&pagetype="+pagetype+"&id="+id+"&txtSearch="+txtSearch;
	Ajax.Request(strURL,AfterLoadPaging);
}

//paging code ends here


function AfterLoadPaging()
{
	Ajax.setShowMessage(1);
	Ajax.setMessage("Fetching..");
	if(Ajax.CheckReadyState(Ajax.request))
	{
		document.getElementById('divPaging').innerHTML=Ajax.request.responseText;	
		document.getElementById('transLoading').style.display='none';

	}
}
function TestFileType( fileName, fileTypes )
{
        if (!fileName)
                return 1;
        
        fileName = fileName.toLowerCase();

        dots = fileName.split(".")
        //get the part AFTER the LAST period.
        fileType = "." + dots[dots.length-1];
        newfiletypes = ".jpeg,."+fileTypes.join(".");
                
        if(newfiletypes.indexOf(fileType) == -1)
        {
                return false;
        }
        else
        {
                return true;
        }
}

//LAYERED WINDOW CODE STARTS HERE

function popupWindow(name, url, width, height, title)
{
	
	var b_version=navigator.appVersion;
	if(b_version.match('MSIE 6.0')!=null) //MSIE 6.0  Done by bhawdeep
	{
		if(parent.window.document.forms.length>0)
		{
			for(var j=0; j<parent.window.document.forms.length ;j++)
			{
				if(parent.window.document.forms[j])
				{
					 var arrSelect=parent.window.document.forms[j].getElementsByTagName("SELECT");
					  for (var i=0; i<arrSelect.length; i++)
					  {
							if (arrSelect[i].type == 'select-one' || arrSelect[i].type == 'select-multiple')
							{
								arrSelect[i].style.display='none';
							}
					   }
				  }
			  }
		 }
   }
	//var strUrl = WWWROOT + "/"+ url;
	
	var strUrl = url;
				
	var ua = navigator.userAgent.toLowerCase();
	isIE = ((ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1)); 
	isGecko = (ua.indexOf("gecko") != -1);
	isSafari = (ua.indexOf("safari") != -1);
	isKonqueror = (ua.indexOf("konqueror") != -1);
	
	if (window.innerHeight && window.scrollMaxY) 
	{
		// Firefox
		browseHeight = window.innerHeight + window.scrollMaxY;
		//browseWidth = window.innerWidth + window.scrollMaxX;
		browseWidth = window.innerWidth - 20;
	}
	else 
	{ 
		// works in Explorer 6 Strict, Mozilla (not FF) and Safari

		browseHeight = document.body.scrollHeight;
		browseWidth = screen.availWidth - 22;
	}
	
	/*******************************************************/
	
	var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt;
	position = 2;
	var version4 = (navigator.appVersion.charAt(0) == "4"); 
	evnt = version4 ? event : null;
	
	if(navigator.appName == "Microsoft Internet Explorer") 
	{
		screenY = document.body.offsetHeight + 150;
		screenX = window.screen.availWidth;
	}
	else 
	{
		screenY = window.outerHeight;
		screenX = window.outerWidth;
	}

	leftvar = (screenX - width) / 2;
	rightvar = (screenY - height) / 2;
	//rightvar = screenY;
	
	if(navigator.appName == "Microsoft Internet Explorer") 
	{
		//leftprop = leftvar;
		//topprop = rightvar;
		
		leftprop = document.body.scrollLeft + ((screenX - width) / 2);
		
		if (window.pageYOffset)
		{
			  topprop = window.pageYOffset
		}
		else if (document.documentElement && document.documentElement.scrollTop)
		{
			topprop = document.documentElement.scrollTop
		}
		else if (document.body)
		{
			  topprop = document.body.scrollTop
		}				
		topprop = topprop + 30; 
		//topprop = document.documentElement.scrollTop + 40;
	}
	else 
	{
		//leftprop = (leftvar - pageXOffset);
		//topprop = parseInt(rightvar - pageYOffset);
		
		leftprop = pageXOffset  + ((screenX - width) / 2);
		topprop = parseInt(pageYOffset + 40,10);
   }

	/********************************************************/
	
	if(screen.height >= height)
		{windowTop = ((screen.height - height)/2) - 80;}
	else
		{windowTop = 0;}
		
	if(screen.width >= width)
		{windowLeft = (screen.width - width)/2;}
	else
		{windowLeft = 0;}
	//alert(windowTop);
	
	windowLeft = leftprop;
	windowTop = topprop;
	//alert(topprop);
	//alert('Page : ' + pageYOffset + ', ' + pageXOffset + ' ---Screen : ' + windowTop + ', ' + windowLeft + ' --- Window : ' + browseHeight + ', ' + browseWidth);
	
	if(isIE)
	{
		frameDivWidth = width;
		frameInnerDivWidth = width;
		frameDivHeight = height-28;
		frameWidth = '100%';
		frameHeight = frameDivHeight - 10;
		lastRowHeight = "8";
	}	
	else
	{
		frameDivWidth = width;
		frameInnerDivWidth = width;
		frameDivHeight = height-20;
		frameWidth = '100%';
		frameHeight = frameDivHeight - 10;
		lastRowHeight = "8";				
	}
	InerframeTableHeight = frameDivHeight - 40;
	if(document.getElementById("overlay"))
	{
		var d = document.getElementById('overlayMain');
		var olddiv = document.getElementById('overlay');
		d.removeChild(olddiv);
	  
		e2 = document.getElementById("overlayMain");
		e2.style.visibility = (e2.style.visibility == "visible") ? "hidden":'';	
	}
	
	var newMainDiv=document.createElement('div');
	newMainDiv.setAttribute('id','overlayMain');
	newMainDiv.style.width= browseWidth+'px';
	newMainDiv.style.height=  browseHeight+'px';
	
	newMainDiv.style.padding = "0px";
	newMainDiv.style.textAlign = "left";
	newMainDiv.style.left = "0px";
	newMainDiv.style.top = "0px";

	newMainDiv.style.position="absolute";
	newMainDiv.style.visibility="hidden";
	newMainDiv.className = "divMainBorderStyle";
	newMainDiv.style.backgroundImage = "url("+WWWROOT+"/images/overlay.gif)";
	
	/*** Inner Main Div ***/
	var newDiv=document.createElement('div');
	var h = height;
	var w = width;
	
	 newDiv.setAttribute('id',name);
	
	newDiv.className="divBorderStyle";
	//newDiv.style.border = borderClass;
	newDiv.style.width= w + "px";
	newDiv.style.height= h + "px";
	newDiv.style.padding = "0px";
	newDiv.style.textAlign = "left";
	newDiv.style.left = windowLeft+"px";
	newDiv.style.top = windowTop+"px";

	newDiv.style.position="fixed";
	newDiv.style.visibility="hidden";
	newDiv.style.overfilter="Alpha(opacity=90)";
	//alert("FW" + frameDivWidth);
	var middleTDwidth1 = frameDivWidth  - 24;
	var middleTDwidth2 = frameDivWidth  - 16;
	
if(url.indexOf("idx_editshowing.php") != -1 || url.indexOf("local_editshowing.php") != -1){
newDiv.innerHTML = '<div  class="divBgImage" style="verticle-align:top;overflow:hidden;border:0px; text-align:left;width:'+frameDivWidth+'px;cursor:default;color:#ffffff; font-family:MS Sans Serif, Arial, Helvetica, sans-serif; font-size:1px; font-weight:bold; margin:0px; padding:0px 0px 0px 0em; white-space:nowrap" ><table border=0 height=28 width="+frameDivWidth+" cellpadding="0" cellspacing="0" style="border:none;"><tr><td width="8"><img src="'+WWWROOT+'/images/popleft.gif" border="0" width=8></td><td width='+middleTDwidth1+' background="'+WWWROOT+'/images/popcenter.gif" style="font-size:12px;color:#ffffff;font-family:sans-serif;">&nbsp;&nbsp;<b>'+title+'</b></td><td width="8" valign="middle" background="'+WWWROOT+'/images/popcenter.gif"><a href="" title="Close" onClick="removeElement1();return false;"><img alt="" align=right valign="middle" border=0 src="'+WWWROOT+'/images/close-btn.gif" /></a></td><td width="8" height=28><img src="'+WWWROOT+'/images/popright.gif"  border="0"></td></tr></table></div><div style="border:none; padding-top:40px; text-align:left;width:'+frameInnerDivWidth+'px;height:'+ frameDivHeight +'px;cursor:default; color:#ffffff; font-family:MS Sans Serif, Arial, Helvetica, sans-serif; font-size:8px; font-weight:bold; margin:0px; padding:0px 0px 0px 0em; white-space:nowrap" style="background-repeat:no-repeat;"><table border=0 bgcolor="#000000" cellpadding="0" cellspacing="0" width="+frameDivWidth+" height='+ frameDivHeight +'px; style="border:none;"><tr><td width="8"  background="'+WWWROOT+'/images/popbodyleft.gif" style="background-repeat:repeat-y; "></td><td width='+middleTDwidth2+' valign="middle" colspan="2"><iframe allowtransparency="true" frameborder="0" style=" margin-right:0px;margin-bottom:5px;" name="testFrame" id="testFrame" width="'+frameWidth+'" height="'+frameHeight+'" src="'+strUrl+'" scrolling="YES" >If you see this you browser dosen\'t support iframes.</iframe></td><td width="8"  background="'+WWWROOT+'/images/popbodyright.gif" style="background-repeat:repeat-y; "></td></tr><tr height="'+lastRowHeight+'"><td width="8" height="'+lastRowHeight+'" background="'+WWWROOT+'/images/popfooterleft.gif" style="background-repeat:no-repeat;vertical-align:bottom;"></td><td width="534" height="'+lastRowHeight+'" valign="middle" colspan="2" background="'+WWWROOT+'/images/popfootercenter.gif" style="background-repeat:repeat-x;vertical-align:bottom;"></td><td width="8" height="'+lastRowHeight+'" background="'+WWWROOT+'/images/popfooterright.gif" style="background-repeat:no-repeat;vertical-align:bottom;"></td></tr></table></div>';
//alert(newDiv.innerHTML);
}
else{


	newDiv.innerHTML = '<div  class="divBgImage" style="verticle-align:top;overflow:hidden;border:0px; text-align:left;width:'+frameDivWidth+'px;cursor:default;color:#ffffff; font-family:MS Sans Serif, Arial, Helvetica, sans-serif; font-size:1px; font-weight:bold; margin:0px; padding:0px 0px 0px 0em; white-space:nowrap;"><table border=0 height=28 width="+frameDivWidth+" cellpadding="0" bgcolor="#000000" cellspacing="0" style="border:none; "><tr><td width="8"></td><td width='+middleTDwidth1+' style="font-size:12px;color:#ffffff;font-family:sans-serif;">&nbsp;&nbsp;<b>'+title+'</b></td><td width="8" valign="middle"><a href="" title="Close" onClick="removeElement1();return false;"><img alt="" align=right valign="middle" border=0 src="'+WWWROOT+'/images/close-btn.gif" /></a></td><td width="8" height=28></td></tr></table></div><div style="border:none; padding-top:40px; text-align:left;width:'+frameInnerDivWidth+'px;height:'+ frameDivHeight +'px;cursor:default; color:#ffffff; font-family:MS Sans Serif, Arial, Helvetica, sans-serif; font-size:8px; font-weight:bold; margin:0px; padding:0px 0px 0px 0em; white-space:nowrap" style="background-repeat:no-repeat;"><table border=0 bgcolor="#000000" cellpadding="0" cellspacing="0" width="+frameDivWidth+" height='+ frameDivHeight +'px; style="border:none;"><tr><td width="8" bgcolor="#000000" style="background-repeat:repeat-y; "></td><td width='+middleTDwidth2+' valign="middle" colspan="2"><iframe allowtransparency="true" frameborder="0" style=" margin-right:0px;margin-bottom:0px;" name="testFrame" id="testFrame" width="'+frameWidth+'" height="'+frameHeight+'" src="'+strUrl+'" >If you see this you browser dosen\'t support iframes.</iframe></td><td width="8"  bgcolor="#000000" style="background-repeat:repeat-y; "></td></tr><tr height="'+lastRowHeight+'"><td width="8" height="'+lastRowHeight+'" bgcolor="#000000" style="background-repeat:no-repeat;vertical-align:bottom;"></td><td width="534" height="'+lastRowHeight+'" valign="middle" colspan="2" bgcolor="#000000" style="background-repeat:repeat-x;vertical-align:bottom;"></td><td width="8" height="'+lastRowHeight+'" bgcolor="#000000" style="background-repeat:no-repeat;vertical-align:bottom;"></td></tr></table></div>';
//alert(newDiv.innerHTML);
}

	document.body.appendChild(newMainDiv);
	document.getElementById('overlayMain').appendChild(newDiv);
}

function o()
{
	el = document.getElementById("overlay");
	el.style.visibility = (el.style.visibility == "hidden") ? "visible" : "visible";
	e2 = document.getElementById("overlayMain");
	e2.style.visibility = (e2.style.visibility == "hidden") ? "visible" : "visible";
			
}
		
function removeElement1() 
{
	var b_version=navigator.appVersion;
	if(b_version.match('MSIE 6.0')!=null) //MSIE 6.0  Done by bhawdeep
	{
		if(parent.window.document.forms.length>0)
		{
			for(var j=0; j<parent.window.document.forms.length ;j++)
			{
				if(parent.window.document.forms[j])
				{
					 var arrSelect=parent.window.document.forms[j].getElementsByTagName("SELECT");
					  for (var i=0; i<arrSelect.length; i++)
					  {
							if (arrSelect[i].type == 'select-one' || arrSelect[i].type == 'select-multiple')
							{
								arrSelect[i].style.display='';
							}
					   }
				  }
			  }
		 }
   }
	if(parent.document.getElementById('txtMsgContents'))
		parent.document.getElementById('txtMsgContents').focus();
	if(parent.document.getElementById('cff_firstname'))
		parent.document.getElementById('cff_firstname').focus();

	/*var d = document.getElementById('overlayMain');
	var olddiv = document.getElementById('overlay');
	d.removeChild(olddiv);
  
	e2 = document.getElementById("overlayMain");
	e2.style.visibility = (e2.style.visibility == "visible") ? "hidden" : "visible";*/

	e2 = parent.document.getElementById("overlayMain");
	e2.style.visibility = (e2.style.visibility == "visible") ? "hidden" : "visible";

	var d = parent.document.getElementById('overlayMain');
	var olddiv = parent.document.getElementById('overlay');
	d.removeChild(olddiv);
}


//LAYERED WINDOW CODE ENDS HERE

function ChangeBorderColor(f,name)
{
        for(var i=0;i<f.length;i++)
        {
                if(f.elements[i].name==name)
                {
					f.elements[i].style.borderColor='#F38724';
                }
                else
                {
					f.elements[i].style.borderColor='';                
                }
        }
}
function saveInappropriateContent(entityId,entityType)
{
	strURL = WWWROOT + "/post/PostInappropriateContent.php?&entityId="+entityId+"&entityType="+entityType;
	Ajax.Request(strURL,AfterLoad1);
	return false;
}

//paging code ends here


function AfterLoad1()
{
	if(Ajax.CheckReadyState(Ajax.request))
	{
		
		document.getElementById("InappropriateContent").innerHTML = 'You have marked this content as Inappropriate Content';
	}
}
function SelectAll(formName,selChkName,checkBoxName)
{
		alert(selChkName);
		alert(checkBoxName);
        var selchkobj=eval("document."+formName+"."+selChkName);
		var chkobj=eval("document."+formName+"."+checkBoxName);
	
		if(chkobj){
		var allchkobj=eval("document."+formName+".allchk");
				if(selchkobj.checked)
				{
					if(!chkobj.length)
					{
						chkobj.checked = true;
					}
					else
					{
						for(i=0;i<chkobj.length;i++)
						{
							if(chkobj[i].disabled == false)
							chkobj[i].checked = true;
						}
					}
				}
				else
				{
					if(!chkobj.length)
					{
						chkobj.checked = false;
					}
					else
					{
						for(i=0;i<chkobj.length;i++)
						{
							chkobj[i].checked = false;
						}
					}
					if(allchkobj)
							allchkobj.checked=false;
				}
		}
}

function CheckIsSelected(formName,checkBoxName,hiddenName,msg)
{
       
	   var obj=eval("document."+formName);
		var chkobj=eval("document."+formName+"."+checkBoxName);
		
		var hidobj=eval("document."+formName+"."+hiddenName);
		var blSelected = false;
        
		if(!chkobj.length)
		{
			if(chkobj.checked)
				blSelected = true;
		}
		else
		{
			for(i=0;i<chkobj.length;i++)
			{
				if(chkobj[i].checked)
				{ 
						blSelected = true;
						break;
				}
				
			}
		}

		if(!blSelected)
        {
            if(msg)
				alert(msg);
			else
				alert('Please Select at least one record.');
            return false
        }
		else
		{
			var values="";
			if(!chkobj.length)
			{
				hidobj.value=chkobj.value
			}
			else
			{
				for(i=0;i<chkobj.length;i++)
				{
					if(chkobj[i].checked)
						values = values+chkobj[i].value+",";
				}
				hidobj.value=values.substring(0,values.length -1);
			}
			
			//alert(hidobj.value);
			return true;
		}
}
var LocationDivId = '';

function FetchLocationCombo(DivId,LocationId,locationtype)
{
	if(locationtype=="country")
	{
	   document.getElementById("cmbStateId").value="";
	   document.getElementById("cmbCityId").value="";
	}
	else if(locationtype=="state")
	{
		document.getElementById("cmbCityId").value="";

	}
	LocationDivId = DivId;
	document.getElementById('transLoading').style.display='';
	myRand=parseInt(Math.random()*99999999);
	strURL = WWWROOT+"/post/PostDisplayLocation.php?LocationId="+LocationId+"&locationtype="+locationtype;
	Ajax.Request(strURL,AfterFetchLocationCombo);

}//sendRequest
function AfterFetchLocationCombo()
{
	Ajax.setShowMessage(1);
	Ajax.setMessage("Fetching..");
	if(Ajax.CheckReadyState(Ajax.request))
	{
		document.getElementById(LocationDivId).innerHTML = Ajax.request.responseText;	
		document.getElementById('transLoading').style.display='none';

	}
}
function ButtonValue(btn) {
var cnt = -1;
for (var i=btn.length-1; i > -1; i--) {
   if (btn[i].checked) {cnt = i; i = -1;}
   }
if (cnt > -1) return btn[cnt].value;
else return null;
}
