/****************************************************************
*  $RCSfile: Common.js,v $																	 	
*  $Revision: 1.8 $							
*  $Author: dkscvs $							
*  $Date: 2009/09/15 16:01:41 $							
*								
*  Copyright (c) 2003 Quark Media house India Pvt Limited.	
*  All Rights Reserved						
*****************************************************************/

//Global variable to hold the value for PO BOX address Checkbox control field.
var IsPOBoxCheckedByUser = false;

//Global Variable to hold the control name that triggered the submit event.
var ControlToSubmit = "";

//This function handles the submit action and checks whether the page is submitted for Search or not.
//If the page is submitted for Serach, then it supresses the submit event, otherwise raises it.
function HandleSubmit(functionName)
{	
	if(ControlToSubmit == "txtSearchKeyword")
	{
		//Reset the variable
		ControlToSubmit = "";
		return false;
	}
	else
	{	
		if (functionName != null && functionName != "")
		{	
			return eval(functionName);
		}
		else
		{	
			return true;
		}
	}
}

//This function is used for validating the email address. 
function CheckEmailFormat(strEmail) 
{

	//Check if the string starts with an integer				
	var firstChar = strEmail.charAt(0);
	var firstCharDigit = parseInt(firstChar);
	//if(!isNaN(firstCharDigit))
	//	return false;

	/*
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(strEmail))
	{
		return true;
	}
	else
	 return false;
	*/
	 //Space is not allowed.
	if (strEmail.indexOf(" ") != -1) 
		return false;
					
	first = 0; last = 0; firstDot=0; lastDot=0;
	// check the @ in an email address. It has to be exactly one @, not on first and not on last position.
	first	  = strEmail.indexOf("@");
	last	  = strEmail.lastIndexOf("@");
	firstDot  = strEmail.indexOf(".");
	lastDot   = strEmail.lastIndexOf(".");
					
	//Check for the string starts with .@ @. and continues dots.
	if (startsWith(strEmail,"..") || startsWith(strEmail,"@.") || startsWith(strEmail,".@") || startsWith(strEmail,"'"))
		return false;

	//Check if the string starts with an integer				
	//var firstChar = strEmail.charAt(0);
	//var firstCharDigit = parseInt(firstChar);
	//if(!isNaN(firstCharDigit))
	//	return false;
						
	if ((first > 0) && (first == last)  && (firstDot > 0) && (lastDot > last+1) && (strEmail.length > (lastDot+2)))
		return true;
	else
		return false;
	
	return true;
}

//This method check & hold the 
function OnPOBoxClickByUser()
{
	if( document.forms[0].elements["POBoxAddress"].checked == true )
		IsPOBoxCheckedByUser = true;
	else
		IsPOBoxCheckedByUser = false;
}		

/// This method remoces special characters and Return true if the address is a PO box address else returns false.
function CheckPOBoxAddress()
{	
	if( IsPOBoxCheckedByUser )
		 return ;
		 
	var sPecialChars = /\$|,|@|#|~|`|\%|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\ |\./g;
	var IsPOBoxAddress = document.forms[0].elements["Address1"].value.replace(sPecialChars,"");
	
	if ( IsPOBoxAddress.toUpperCase().indexOf("POBOX") != -1 )
		document.forms[0].elements["POBoxAddress"].checked = true; 
	else
		document.forms[0].elements["POBoxAddress"].checked = false; 
}

//Generic method to disable all buttons on form before submit
function DisableButtons()
{
	//Get all the button fields
	var elements = document.forms[0].getElementsByTagName("INPUT");
	for(i=0; i<elements.length; i++)
	{
		var field		= elements[i];
		var fieldType	= field.type;
		
		if (fieldType != null && ( fieldType == "button" || fieldType == "submit" || fieldType == "image"))
		{
			field.disabled = true;
		}
	}
	/*
    for (index=0; index<document.links.length; index++) 
    {
		var link = document.links[index];
		link.disabled = true;
	}
    for (index=0; index<document.anchors.length; index++) 
    {
		var link = document.anchors[index];
		link.disabled = true;
    }
    */
}

function DisableButtonsEx()
{
	//Get all the button fields
	var elements = document.forms[0].getElementsByTagName("INPUT");
	for(i=0; i<elements.length; i++)
	{
		var field		= elements[i];
		var fieldType	= field.type;
		
		if (fieldType != null)
		{
			if(fieldType == "button")
			{
				field.disabled = true;
			}
			else if(fieldType == "submit" || fieldType == "image")
			{
				if(elements[field.name + '_Dummy'])
				{
					field.style.display="none";
					elements[field.name + '_Dummy'].style.display="inline";
				}
			}
		}
	}

	/*
    for (index=0; index<document.links.length; index++) 
    {
		var link = document.links[index];
		link.disabled = true;
	}
    for (index=0; index<document.anchors.length; index++) 
    {
		var link = document.anchors[index];
		link.disabled = true;
    }
	*/
}

//Starts with function for string manupulation.
function startsWith(value, search)
{
	for(start=0;start<value.length+1-search.length;start++)
		if (value.substr(start,search.length) == search) return true;
	return false;
}

// This function Disable the right click
function DisableRightClick(e) //Function that will execute on right click
{	
	if (window.Event) 
	{
		if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2))
			return false;
	}		
	else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3))
	{
		alert("Right click is disable.");
		event.cancelBubble = true, event.returnValue = false;
		return false;
	}
	return true;
}

//This function trims the leading and trailing blanks
function trim(value)
{
	while(value.charAt(value.length-1) == " ")
	{
		value = value.substring(0,value.length-1);
	} 
	while(value.substring(0,1) ==" ")
	{
		value = value.substring(1,value.length);
	}
	return value;
}

//Generic Function to check for Special Characters.
function checkSpecialCharacters()
{
	var SPECIAL_CHARACTER_MSG = "The characters '<' or '>' are not allowed. Please re-enter the value.";
	
	//Get all the text fields
	var count = document.forms[0].elements.length;
	
	for(i=0; i<count; i++)
	{
		var field		= document.forms[0].elements[i];
		var fieldType	= field.type;
		
		if (fieldType != null && (fieldType == "text" || fieldType == "textarea" || fieldType == "password"))
		{
			if( field.name == "txtSearchCategory" && field.value != "" )
				field.value = "";
				
			//Check for special characters
			if ((field.value.indexOf("<") > -1 || field.value.indexOf(">") > -1))
			{
				//Show the message
				alert(SPECIAL_CHARACTER_MSG);
				
				//Set the focus
				field.focus();
				field.select();
				
				return false;
			}
		}
	}
	return true;
}

//Generic Function to check the mandatory Fields.
function checkMandatoryFields(formName, fieldNames)
{
	var MANDATORY_FIELD_MSG = "Please complete the required fields.";
	//get form
	var objForm = formName;//document.forms[formName];
	//get the mandatory fields
	var mandatoryFields = fieldNames.split(",");
	
	var i=0;
	
	//To check the mandatory field has any value or not
	var isValueEntered = true;
	
	//iterate all the mandatory fields and check whether value is entered or not. If not show alert message
	//and set the focus to the field
	while(i<mandatoryFields.length && isValueEntered)
	{
		if(objForm.elements[mandatoryFields[i]] != null && objForm.elements[mandatoryFields[i]] != "undefined" && (trim(objForm.elements[mandatoryFields[i]].value) == "" || trim(objForm.elements[mandatoryFields[i]].value) == "{00000000-0000-0000-0000-000000000000}"))
		{
			isValueEntered = false;
			break;
		}
		i++;
	}
	
	if(!isValueEntered)
	{
		alert(MANDATORY_FIELD_MSG);
		if(!objForm.elements[mandatoryFields[i]].disabled)
		{
			objForm.elements[mandatoryFields[i]].focus();
			try
			{
				//Check the type, if textbox then select
				var objType = objForm.elements[mandatoryFields[i]].type;
				if (objType != null && objType == "text")
				{
					objForm.elements[mandatoryFields[i]].select();
				}
			}
			catch(exception)
			{
				//Do nothing
			}
		}
	}
	
	return isValueEntered;
}

//Method to mask the textbox for integer values
function maskInteger(e)
{	
	var inputKey;
	if(window.event) 
	{
		inputKey = e.keyCode;
	}
	else if(e.which)
	{
		inputKey = e.which;
	}
	
	if (inputKey != 13)
	{
		if ((inputKey < 48 || inputKey > 57) && (inputKey != 8) && (inputKey != 9))
		{
			return false;
		}
	}
	return true;
}

//Method to mask the textbox for decimal values
function maskDecimal(e)
{
	var inputKey;
	var inputValue;
	if(window.event) 
	{
		inputKey	= e.keyCode;
		inputValue	= e.srcElement.value;
	}
	else if(e.which)
	{
		inputKey	= e.which;
		inputValue	= e.target.value;
	}
	
	if (inputKey != 13)
	{
		if ((inputKey < 48 || inputKey > 57) && (inputKey != 8) && (inputKey != 9) && (inputKey != 46))
		{
			return false;
		}
		
		if (inputValue != null && inputValue.indexOf(".") != -1)
		{
			if (inputKey == 46)
			{
				return false;
			}
		}
	}
	return true;
}

//Method to format the Textbox value as 0.00 (to be used for onblur event)
function FormatPrecision(textbox,totallength,precisionlength)
{
	var val	= textbox.value;
	if(val == "")
	{
		return;
	}
	
	var index = val.indexOf(".");
	if(index != -1)
	{
		var valueBeforeDot = val.substr(0,index);
		var valueAfterDot  = val.substr(index+1,val.length);

		if(valueBeforeDot == "")
		{
			valueBeforeDot = "0";
		} 
		
		if(valueAfterDot != "")
		{ 
			if(valueAfterDot.length > precisionlength)
			{
				textbox.value = valueBeforeDot + "." + valueAfterDot.substr(0, precisionlength);
			}
			else
			{
				var zero = "0000";
				textbox.value = valueBeforeDot + "." + valueAfterDot + zero.substr(0, precisionlength - valueAfterDot.length);
			}
		}
		else
		{
			textbox.value = valueBeforeDot + ".00";
		}
	}
	else
	{	
		if(val == "")
		{
			val = "0";			
		}
		textbox.value = val + ".00";
	}
}

//Generic Function to Check whether the field value is Numeric
function isNumeric(fieldValue)
{
	var strValue = String(fieldValue);
	var len	= strValue.length;
	if(len>0)
	{
		for(var i=0; i < len; i++)
		{
			var charCode = strValue.charCodeAt(i); 
			if((charCode < 48 || charCode > 57))
			{
				return false;
			}
		}
		return true;
	}	
	return false;
}

function trimSpaceAndReturn(value)
{

	retval	=	new String(value);
	
	//Removing the extra spaces and "\r\n" in the end
	while(retval.charAt(retval.length-1) == " " || (retval.lastIndexOf("\n")!= -1 && retval.lastIndexOf("\n") == (retval.length - 2))) 
	{
		retval = retval.charAt(retval.length-1) == " " ? retval.substring(0,retval.length-1) : retval.substring(0,retval.length -2);
		
	} 
		
	//Removing the extra spaces and "\r\n" in the beginning
	while(retval.substring(0,1) == " " || retval.indexOf("\r\n") == 0)
	{
		retval = retval.substring(0,1) ==" " ? retval.substring(1,retval.length) : retval.substring(2,retval.length);
	}
	
	return retval;
}

////////////////////////////////////////////////////////////Modal Window functions starts here///////////////////////
var winModalWindow;
var RELOAD = "RELOAD";
var SUBMIT = "SUBMIT";
 
function IgnoreEvents()
{
	if (winModalWindow && !winModalWindow.closed) 
	{
		winModalWindow.focus();
		return false
	}
}

var mozillaversion16 = ((navigator.appName== "Netscape") && (navigator.userAgent.indexOf("Gecko/20040113")!=-1) && (navigator.userAgent.indexOf("rv:1.6")!=-1))
var mozillaversion11 = ((navigator.appName== "Netscape") && (navigator.userAgent.indexOf("Gecko/20020826")!=-1) && (navigator.userAgent.indexOf("rv:1.1")!=-1))
var netscapeVersion7 = ((navigator.appName== "Netscape") && (navigator.userAgent.indexOf("Netscape/7")!=-1))?true:false;
var ie50 = (navigator.userAgent.indexOf("MSIE 5.0")!=-1)?true:false; 
var Mac = (navigator.appVersion.indexOf("Mac")!=-1)?true:false; 

/*
This function will identify the browser whether it supports modal dialog or not.
If the browser doesn't support modal dialog then new window will be launched and
it will be act as a modal window.
*/
function ShowCustomizeDialog(Page,Width,Height)
{
	if (window.showModalDialog)
	{
		if(Mac && ie50)
		{
			LaunchSimulatedModalWindow(Page,Width,Height);
		}
		else
		{
			var retVal = "";
			var windowIE50 = (navigator.appVersion.indexOf("MSIE 5.0")!=-1)?true:false;   
   			var windows =(navigator.appVersion.indexOf("Windows")!=-1)?true:false; 

			//-----------WorkAround for the Problem in Windows/IE 5.0----------------
			//To solve the problem of opening a new window in IE 5.0, we should use
			//<iframe>. The following code will do the same.
			if(windowIE50 && windows)
			{
				var SlashAfterVirtualDirectory =Page.indexOf("/",Page.indexOf("/",Page.indexOf("/")+2)+1);
				var lastQuestionMark = Page.lastIndexOf("?");
				var replaceTo = Page.substring(SlashAfterVirtualDirectory+1,lastQuestionMark);
				var ReplacedUrl = Page.replace(replaceTo,"Common/QDialogLauncher.aspx") + "&DialogName=" + replaceTo;
				retVal = window.showModalDialog(ReplacedUrl,"ModalDialog","dialogWidth="+Width+"px;dialogHeight="+Height+"px;scrollbars=no");
			}
			else
			{
				retVal = window.showModalDialog(Page,"ModalDialog","dialogWidth="+Width+"px;dialogHeight="+Height+"px;scrollbars=no");		
			}
			
			if(retVal == RELOAD)
			{
				self.document.forms[0].submit(); //reload() is not supported by MAC IE 5.2
			}
			else if(retVal == SUBMIT)
			{
				self.document.forms[0].submit();
			}
			else
				return false;
		}
	}
	else
	{
		LaunchSimulatedModalWindow(Page,Width,Height);
	}
  
}
/*********** Used for launching simulated modal window for Netscape,Mozilla other than IE **********/
function LaunchSimulatedModalWindow(Page,Width,Height)
{
	if(navigator.appName == "Netscape")
	{
		window.top.captureEvents (Event.CLICK|Event.FOCUS)
	}
	window.top.onclick = IgnoreEvents
	window.top.onfocus = HandleFocus
	
	//call this method to disable the parent form elements and links.
	if(netscapeVersion7 || mozillaversion11 || mozillaversion16 || (Mac && ie50))
		disableForms();
	winModalWindow =  window.open (Page,"ModalDialog","dependent=yes,width="+Width+",height="+Height+", scrollbars=yes");
	window.opener = winModalWindow;
	winModalWindow.focus();
}
//************ Used to close the window **************/
function CloseWindow()
{
	if(window.showModalDialog)
	{
		if(Mac && ie50)
		{
			HandleFocus();
			window.parent.close();
		}
		else
			top.close();
	}
	else
	{
		HandleFocus();
		window.parent.close();
	}
}

var firstTime = true;
//Call the set focus method through setTimeOut as without setTimeout it gives some problems in Netscape 7 and Mozilla 1.6
function HandleFocus()
{
	if(netscapeVersion7 || mozillaversion11 || mozillaversion16)
		setTimeout("setFocus()", 50);
	else
		setFocus();
		
	return true;
}

function setFocus()
{
	
	if (winModalWindow)
	{
		if (!winModalWindow.closed)
		{
			winModalWindow.focus();
		}
		else
		{
			if(navigator.appName == "Netscape")
			{
				window.top.releaseEvents (Event.CLICK|Event.FOCUS)
			}
			window.top.onclick = ""
			if(netscapeVersion7 || mozillaversion11 || mozillaversion16 || (Mac && ie50))
				enableForms();
		}
    }
	return false
}

/*
Parent page which has child window should call this function on onUnload event 
to close the child window if it exists.
*/
function CloseChildOnParentUnLoad()
{
 if(window.opener.name == "ModalChild")
 {
	window.opener.close();
 }
 
}

/*
To close the child and relod the parent from the child.
This should be called from the child.
*/
function CloseChildReloadParent()
{
	if (window.showModalDialog)
	{
		window.returnValue = RELOAD;
		window.close();
	}
	else
	{
		window.opener.location.reload();
		window.close();
	}
}

/*
To close the child and submit the parent from the child.
This should be called from the child.
*/
function CloseChildSubmitParent()
{
	if (window.showModalDialog)
	{
		window.returnValue = SUBMIT;
		window.close();
	}
	else
	{
		window.opener.document.forms[0].submit();
		window.close();
	}
}

function CloseChildWindow()
{
	window.close();
}

function CheckLength(field,len)
{
	var maxlen = parseInt(len);
	if (field.value.length > maxlen)
		field.value = field.value.substring(0, maxlen);
}

function changeCursorOnMouseOver(field)
{
	var ie50 = (navigator.appVersion.indexOf("MSIE 5")!=-1)?true:false;  
	var windows =(navigator.appVersion.indexOf("Windows")!=-1)?true:false; 
	if(ie50 && windows)
	{
		field.style.cursor = 'hand';
		field.style.color = "C86837";
	}
	else
	{
		field.style.cursor = 'pointer';
		field.style.color = "C86837";
	}
}

function changeCursorOnMouseOut(field)
{
	field.style.cursor = 'default';
	field.style.color = "928D57";
}


// Since links in Netscape can't be disabled, preserve onclick event handlers while they're "disabled." 
// Restore when reenabling the main window.
var IELinkClicks
// Disable form elements and links and the anchors(Anchors should have the name or Id property).
function disableForms() 
{
	var index;
	IELinkClicks = new Array()
	disableFormElements();
    for (index = 0; index < document.links.length; index++) 
    {
		IELinkClicks[index] = document.links[index].onclick
        document.links[index].onclick = IgnoreEvents
    }
    var linkLength = document.links.length
    for (index = 0; index < document.anchors.length; index++) 
    {
		IELinkClicks[linkLength+index] = document.anchors[index].onclick
		document.anchors[index].onclick = IgnoreEvents
    }
}

/**
* The method disables various form elements of the passed form object.
*/
function disableFormElements()
{
	formObj = document.forms[0];
	if(!formObj || formObj == null)
	{
		return;
	}
	
	var elements = formObj.elements;
	var index;
	for(index = 0; index < elements.length; index++)
	{
		try
		{
			if(elements[index].type != "hidden")
			{
				if(elements[index].type == "text")
				{
					elements[index].readonly = true;
				}
				else if(elements[index].type == "select-one")
				{
					elements[index].onchange = "window.event.returnValue = false; return false;"
				}
				else if(elements[index].type != "radio" && elements[index].type != "checkbox")
				{
					elements[index].disabled = true;
				}
			}
		}
		catch(exception)
		{
			//dont do anything
		}
	}
}


// Restore IE form elements and links to normal behavior.
function enableForms() 
{
	enableFormElements();
    for (index = 0; index < document.links.length; index++) 
    {
		document.links[index].onclick = IELinkClicks[index]
    }
    var linksLength = document.links.length;
    for (index = 0; index < document.anchors.length; index++) 
    {
		document.anchors[index].onclick = IELinkClicks[linksLength+index]
    }
   
}
/**
* The method enables various form elements of the passed form object.
*/
function enableFormElements()
{
	formObj = document.forms[0];
	if(!formObj || formObj == null)
	{
		return;
	}
	
	var elements = formObj.elements;
	var index;
	for(index = 0; index < elements.length; index++)
	{
		try
		{
			if(elements[index].type != "hidden")
			{
				if(elements[index].type == "text")
				{
					elements[index].readonly = false;
				}
				else if(elements[index].type == "select-one")
				{
					elements[index].onchange = "window.event.returnValue = true; return true;"
				}
				else if(elements[index].type != "radio" && elements[index].type != "checkbox")
				{
					elements[index].disabled = false;
				}
			}
		}
		catch(exception)
		{
			//dont do anything
		}
	}
}
//Generic Function to Check whether the field value is AlphaNumeric
function isAlphaNumeric(fieldValue)
{
	
	var len = fieldValue.length;
	if(len>0)
	{
		for(var i=0; i < len; i++)
		{
			var strValue = fieldValue;
			var charCode = strValue.charCodeAt(i); 
			if((charCode >= 48 && charCode <= 57) || (charCode >= 65 && charCode <=90) || (charCode >=97 && charCode <= 122))
			{
				//return true;
			}
			else
			{
				return false;
			}
		}
		return true;
	}	
	return false;
}

//Populate the Shipment Types depending upon the country ID
//Requires the ShipmentTypesList mapping data to be embedded in the page
function PopulateShipmentTypes(dropdownList, countryID, defaultShipmentTypeID, showSelect)
{
	if (ShipmentTypesList != null)
	{
		//Check whether to show select
		var bShowSelect = true;
		if (showSelect != null)
		{
			bShowSelect = showSelect;
		}
	
		//Clear the Shipping Method List and re-populate it
		document.forms[0].elements[dropdownList].options.length = 0;
		
		if (countryID != null && countryID != "")
		{
			//Get the Shipment Types for the selected country
			var objShipmentTypes = ShipmentTypesList[countryID];
			var strShipmentTypeID;
			var strShipmentTypeValue;
			
			if (objShipmentTypes != null && objShipmentTypes.length > 0)
			{
				var index = 0;
				if (bShowSelect)
				{
					//Show the Select>>
					document.forms[0].elements[dropdownList].options[index] = new Option("Select >>","");
					index++;
				}
				var defaultShipmentTypeIDIndex = 0;
				//Populate the dropdown List with Shipment Types
				for(strShipmentTypeID in objShipmentTypes)
				{
					strShipmentTypeValue = objShipmentTypes[strShipmentTypeID];
					document.forms[0].elements[dropdownList].options[index] = new Option(strShipmentTypeValue,strShipmentTypeID);
					if( defaultShipmentTypeID != null && defaultShipmentTypeID != "" && strShipmentTypeID === defaultShipmentTypeID )
						defaultShipmentTypeIDIndex = index; 
					
					index++;
				}
				
				/*
				//////// ON MAC IE5.2 document.forms[0].elements[dropdownList].value STATEMENT IS NOT WORKING \\\\\\\
				//Select the default Shipment Type
				if (defaultShipmentTypeID != null && defaultShipmentTypeID != "")
				{
					document.forms[0].elements[dropdownList].value = defaultShipmentTypeID;
					if(document.forms[0].elements[dropdownList].value == null || document.forms[0].elements[dropdownList].value == "")
					{
						document.forms[0].elements[dropdownList].selectedIndex = 0;
					}
				}
				*/
				if( defaultShipmentTypeIDIndex != 0 )
					document.forms[0].elements[dropdownList].selectedIndex = defaultShipmentTypeIDIndex;
				else
					document.forms[0].elements[dropdownList].selectedIndex = 0;	
			}
			else
			{
				//Show the message Not Available
				document.forms[0].elements[dropdownList].options[0] = new Option("-- Not Available --","");
			}
		}
	}
}


/*
Count down until any date script-
By JavaScript Kit (www.javascriptkit.com)
Over 200+ free scripts here!
Modified by Robert M. Kuhnhenn, D.O. 
on 5/30/2006 to count down to a specific date AND time
and on 10/20/2007 to a new format
*/


//-->change the text below to reflect what you want the script to display when the target date and time are reached, limit to 20 characters
var current="Qwirkle Cubes Has Arrived!"
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

function resetFocus(){
this.Blur();
}

function Right(str, n)
{
      if (n <= 0)
          return "";
      else if (n > String(str).length)
          return str;
      else
   {
          var iLen = String(str).length;
          return String(str).substring(iLen, iLen - n);
      }
}

function countdown(yr,m,d,hr,min){
/*
theyear=yr;themonth=m;theday=d;thehour=hr;theminute=min
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000) {
todayy+=1900 }
var todaym=today.getMonth()
var todayd=today.getDate()
var todayh=today.getHours()
var todaymin=today.getMinutes()
var todaysec=today.getSeconds()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
futurestring=montharray[m-1]+" "+d+", "+yr+" "+hr+":"+min
dd=Date.parse(futurestring)-Date.parse(todaystring)
dday=Math.floor(dd/(60*60*1000*24)*1)
dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
document.forms[0].elements["countermessage"].style.border="none";
if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=0){
document.forms[0].elements["dsec"].value="00";
document.forms[0].elements["countermessage"].value=current;
document.forms[0].elements["countermessage"].style.display="block";
document.forms[0].elements["countdownRow"].style.visibility = "hidden";
document.forms[0].elements["captionRow"].style.visibility = "hidden";
return;
}
else {
document.forms[0].elements["countermessage"].style.display="none";
document.forms[0].elements["dday"].value=Right("0"+dday.toString(),2);
document.forms[0].elements["dhour"].value=Right("0"+dhour.toString(),2);
document.forms[0].elements["dmin"].value=Right("0"+dmin.toString(),2);
document.forms[0].elements["dsec"].value=Right("0"+dsec.toString(),2);
setTimeout("countdown(theyear,themonth,theday,thehour,theminute)",1000);
}
*/
}


////////////////////////////////////////////////////////////Modal Window functions ends here///////////////////////


/***************************************************************
 *  $Log: Common.js,v $
 *  Revision 1.8  2009/09/15 16:01:41  dkscvs
 *  -Replaced “My Wishlist” with “My Account” in the header
 *  -Replaced “Customer Service” with “My Wishlist” in the footer
 *  -Updated Customer Service page
 *  -Updated FAQ page
 *  -Added Guest Checkout functionality
 *  -Fix for free text search
 *  -Fix for double quotes in user reviews
 *
 *  Revision 1.7  2009/03/10 21:17:01  dkscvs
 *  Countdown timer for Qwirkle Cubes
 *  Bob fix for Omniture problem of more orders than carts
 *
 *  Revision 1.6  2008/08/28 18:49:16  nhase
 *  *** empty log message ***
 *
 *  Revision 1.5  2008/03/25 21:04:23  dkscvs
 *  Patch 50
 *
 *  Revision 1.1  2007/09/25 13:05:54  sackumar
 *  Added changes related to Bug# 3248
 *
 *  Revision 1.16  2007/06/13 12:37:05  rlakshmi
 *  checking in for bug # 3235.
 *
 *  Revision 1.13  2005/09/29 15:09:35  avsingh
 *  Updated the IsNumeric() method.
 *
 *  Revision 1.12  2005/09/28 09:31:53  apsingh
 *  Fixed #387178.
 *
 *  Now email ID with numeric prefix accepted.
 *
 *  Revision 1.11  2005/09/28 04:31:43  avsingh
 *  Added support to simply return if textbox value is empty string in FormatPrecision() javascript method.
 *
 *  Revision 1.10  2005/09/26 11:25:26  avsingh
 *  - Added method maskDecimal() to mask the textbox for decimal values.
 *  - Added method FormatPrecision() to format the textbox value as 0.00
 *
 *  Revision 1.9  2005/09/22 05:51:08  apsingh
 *  Added function DisableRightClick().
 *
 *  Revision 1.8  2005/08/31 13:44:00  apsingh
 *  Fixed #381203.
 *
 *  Added ''(space) in specialChar array list.
 *
 *  Revision 1.7  2005/08/30 11:51:56  apsingh
 *  comment document.forms[formname] formname passing document.forms[0].
 *
 *  Revision 1.6  2005/08/25 15:40:13  avsingh
 *  Modified the DisableButtonsEx() javascript method.
 *
 *  Revision 1.5  2005/08/24 14:09:57  apsingh
 *  Added  OnPOBoxClickByUser(), CheckPOBoxAddress()
 *  for Automatic Identification of PO box address.
 *
 *  reviewer : sachin
 *
 *  Revision 1.4  2005/08/24 12:10:31  avsingh
 *  Added the javascript methods DisableButtons() and DisableButtonsEx().
 *
 *  Revision 1.3  2005/08/18 13:42:32  apsingh
 *  Added HandleSubmit function for Netscape Issues.
 *
 *  Revision 1.2  2005/08/12 12:28:27  apsingh
 *  Added SpecialCharacter.js method
 *  Handling of special characters.
 *
 *  Revision 1.1.1.1  2005/08/08 17:10:57  mercury_build
 *  Inital Check-in for QCMS 2.8 after 2.5 version
 *
 *  Revision 1.1.2.7  2005/07/04 10:49:30  apsingh
 *  If combo box is created with javascript then on mac IE5.2 comboBox.value assignment does not work.
 *  Changed the code to work with selectedIndex.
 *
 *  Revision 1.1.2.6  2005/06/13 15:12:57  avsingh
 *  Updated the javascript method checkMandatoryFields() for selecting fields.
 *
 *  Revision 1.1.2.5  2005/06/10 13:22:13  avsingh
 *  Modified the method PopulateShipmentTypes(). (related to International Shipping)
 *
 *  Revision 1.1.2.4  2005/06/06 14:17:16  avsingh
 *  Added support in method checkMandatoryFields() to select the related field in case the validation of field value fails.
 *
 *  Revision 1.1.2.3  2005/05/29 13:53:33  avsingh
 *  Added the common method maskInteger().
 *  Added the common method PopulateShipmentTypes().
 *
 *  Revision 1.1.2.2  2005/04/11 07:08:17  apsingh
 *  Fixed #336936
 *  Incorrect email id (starting with a numeric ) user account is created.
 *
 *  Revision 1.1.2.1  2005/03/16 11:09:07  sackumar
 *  Initial check-in for Estore 2.5.
 *
 *  Revision 1.1  2005/02/10 09:56:06  mdas
 *  Add Login.js and Common.js.
 *
 *  Revision 1.18.4.2  2005/02/02 13:38:55  mdas
 *  Fixed #333501, #333537
 *
 *  Revision 1.18.4.1  2004/11/23 11:37:48  mdas
 *  Credit Card security code changes.
 *
 *  Revision 1.19  2004/11/22 10:01:31  mdas
 *  Credit Card security code changes.
 *
 *  Revision 1.18  2004/09/15 13:22:22  mdas
 *  Changes done to open a modal dialog window through window.open for MAC IE 9.2 also
 *
 *  Revision 1.17  2004/09/14 12:29:29  mdas
 *  Added scrollbar=yes
 *
 *  Revision 1.16  2004/09/14 10:58:42  sackumar
 *  Added changes for the simulated modal dialog.
 *
 *  Revision 1.15  2004/09/02 11:31:31  mdas
 *  Added changeCursorOnMouseout function and chnaged the color to red on mouseover
 *
 *  Revision 1.14  2004/08/19 06:40:37  mdas
 *  Made cursor=hand property available for all versions gereater than  Internet Explorer 5 on Windows platform.
 *
 *  Revision 1.13  2004/08/06 11:48:42  mdas
 *  Handled Windows/IE 5.0 Modal Dialog problem.
 *
 *  Revision 1.12  2004/08/04 06:27:17  mdas
 *  Added new method "changeCursorOnMouseOver" for changing the mouse cursor shape.
 *
 *  Revision 1.11  2004/07/13 11:49:51  sackumar
 *  stop using the email format algorithm got from internet, instead use the algorithm used at Customer service and acll center.
 *
 *  Revision 1.10  2004/05/12 12:25:32  pvasikar
 *  While checking Form elements against undefined, check against "undefined" not against undefined.
 *
 *  Revision 1.9  2004/05/11 08:57:26  pvasikar
 *  reload() is replaced by submit() since reload() is not supported by MAC IE.
 *
 *  Revision 1.8  2004/05/04 06:48:32  pvasikar
 *  New Check Email Format function is added old one is removed.
 *
 *  Revision 1.7  2004/03/22 14:26:13  pvasikar
 *  Email validation done for special characters.
 *
 *  Revision 1.6  2004/03/15 07:27:09  pvasikar
 *  Error messages corrected as per usecase.
 *
 *  Revision 1.5  2004/02/18 14:37:54  pvasikar
 *  Added function to check the length of the field.
 *
 *  Revision 1.4  2004/02/17 14:45:24  mvijay
 *  Changes done for showing Modal Window
 *
 *  Revision 1.3  2004/02/17 05:07:48  pvasikar
 *  no message
 *
 *  Revision 1.2  2004/02/10 12:56:37  pvasikar
 *  no message
 *
 *  Revision 1.1.1.1  2004/01/28 04:37:56  mercury_build
 *  Initial Version
 *
 *  Revision 1.1  2004/01/22 13:17:17  nrajavelu
 *  no message
 *				  
 *  
 *
 *  Copyright (c) 2003 Quark Media house India Pvt Limited.	
 *  All Rights Reserved						
 ***************************************************************/

