
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

function fixPNG(myImage) 
{

    if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
    {
       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? 
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
	   myImage.outerHTML = strNewHTML	  
    }
}

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 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 isValidUrl(url)
{	
	var pattern = /http:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/;
	return pattern.test(url);
}

function isValidUSPhone(ph)
{	
	var pattern = /(\d)?(\s|-)?(\()?(\d){3}(\))?(\s|-){1}(\d){3}(\s|-){1}(\d){4}/;
	return pattern.test(ph);
}

function trim(str)
{
	return str.replace(/^\s*$/g,"");
}

function CompareDateWithCurrentDate(date1, date2, type)
 {
 	if(date1!=0 && date2.length!=0 )
	{
	  var StartDate = date1;
	  var EndDate = date2;
	 
	  var arrStart = StartDate.split("-");
	  var arrEnd = EndDate.split("-");          
	
 		if(parseInt(arrEnd[2])<parseInt(arrStart[2]))
		{ // end day is less than start day		
		  return false; 
		}
  		else if(parseInt(arrEnd[2])==parseInt(arrStart[2]))
		{ // end day  = start day
			if(parseInt(arrEnd[0])<parseInt(arrStart[0]))
			{	// end year < start year
					// alert('compare year');
					 return false;
			}
	  		else if(parseInt(arrEnd[0])==parseInt(arrStart[0]))        
			{ // end year = start year. day is same, year is same. Now, compare months
			 	if(type == 'GTE')
				{
					if(arrEnd[1] < arrStart[1])
					{
					//alert('compare months');
					return false;
					}
					else return true;
				}
				else if(type == 'GT')
				{
					if(arrEnd[1] <= arrStart[1])
					{
					//alert('compare months');
					return false;
					}
					else return true;
				}				
		   }
		   else return true;
		}		
  		else return true;                        
 	}
	else
 	{
		return true;
 	} 
}

function isValidZipcode(str) 
{
	var pattern = /\d{5,}/; 
	return pattern.test(str);
}

function isValidImage(str)
{	
	var pattern =/^((.jpg)|(.JPG)|(.JPEG)|(.jpeg)|(.GIF)|(.gif)|(.png)|(.PNG))$/;
	var ext = str.substr(str.length-4,str.length);
	return pattern.test(ext);
}

function MoveNext(mVal,frm)
{
	var TotalDivs = document.getElementsByTagName("td");
	var DivsLength = TotalDivs.length;
	var pre = frm.previous;
	var next = frm.next;
	if(pre.disabled=true)
	{
		pre.disabled=false;
	}	
	var dl;
	for(dl=0;dl<DivsLength;dl++)
	{
		if(TotalDivs[dl].className=="tabcontent")
		{
			if(TotalDivs[dl].style.display=="block")
			{
				var divId = TotalDivs[dl].id;
				var NextId = divId.substr(8);
				if(parseInt(NextId)==parseInt(mVal)-1)
				{
					next.disabled=true;
					expandtab('maintab', NextId);
					break;
				}
				else if(parseInt(NextId)<parseInt(mVal))
				{
					expandtab('maintab', NextId);
					break;
				}
				else
				{
					next.disabled=true;
					break;
				}	
			}	
		}
	}
}

function MovePrevious(frm)
{
	var TotalDivs = document.getElementsByTagName("td");
	var pre = frm.previous;
	var DivsLength = TotalDivs.length;
	var next = frm.next;
	if(next.disabled=true)
	{
		next.disabled=false;
	}	
	var dl;
	for(dl=0;dl<DivsLength;dl++)
	{
		if(TotalDivs[dl].className=="tabcontent")
		{
			if(TotalDivs[dl].style.display=="block")
			{
				var divId = TotalDivs[dl].id;
				var CurrentId = divId.substr(8);
				var PreviousId = parseInt(CurrentId) - 2;
				if(PreviousId==0)
				{
					pre.disabled=true;
					expandtab('maintab', PreviousId);
					break;
				}
				else if(PreviousId>=0)
				{
					expandtab('maintab', PreviousId);
					break;
				}
				else
				{
					pre.disabled=true;
					break;
				}	
			}	
		}
	}
}


function sendAjaxRequest(url, divId) {

	// This function is getting used in registration process

   // Open PHP script for requests
  
   http.open('get',url);
   http.onreadystatechange = handleAjaxResponse;
   divhandler.divtag = divId;
   http.send(null);

}//sendAjaxRequest

function handleAjaxResponse() {

   if(http.readyState == 4 && http.status == 200){

      // Text returned FROM the PHP script
	var response = eval('(' + http.responseText + ')');
      if(response) {
         // UPDATE ajaxTest content
         document.getElementById(divhandler.divtag).innerHTML = response.htmlStr;
		 document.getElementById("msgTD").innerHTML = response.msgStr;
      }
   }
  
}//handleAjaxResponse