/* testing purpose for checkin and check out for general 
 * To show error message box
 */
 
/*---------------------------------------------------------------*/
 
 
/*---------------------------------------------------------------*/
 var responseAction = 0;
 var commentsArray;
 function displayErrorMessages(msg){
 	var err_div  = document.getElementById('error_message');		
  	err_div.style.display = 'block';
	err_div.innerHTML = '<div class="'+document.getElementById('errorid').value+'">'+msg +'</div>';
  }

  function displayCommentsConfMessages(msg){
	var err_div  = document.getElementById('comment_error_message');		
  	document.getElementById('comment_error_message').style.display = '';
	document.getElementById('comment_error_message').innerHTML = msg;
	//err_div.style.display = '';
	//err_div.innerHTML = msg;
  }

/* Function to hide comments errors messages*/

 function hideCommentsConfErrorMessages(pageNum,currentPageItems){
 	document.getElementById('comment_error_message').style.display = 'none';
	document.getElementById('comment_error_message').innerHTML = '';
	var ptMach = /Safari/;
	if(navigator.userAgent.match(ptMach)){
		commentsArray.loadData();
	}
	if(currentPageItems == 1){
		commentsDisplay.goToPage(pageNum - 1);
	}else{
		commentsDisplay.goToPage(pageNum);
	}
 }

 function clearErrorMessages(){
 	var err_div  = document.getElementById('error_message');		
  	err_div.style.display = 'none';
	err_div.innerHTML = '' ;
 }
  
  function isComboSelected(elem, helperMsg){
	if(elem.value == 0){
		displayErrorMessages(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
	}
	return true;
}

/* 
 * The function will write the album url in a textarea of left menu panel
*/
function generateAlbumUrl(message) {
	document.getElementById('albumurl').value = message;
}

/* 
 * The function performs the visibility of a div in a left menu panel
*/
function doVisibility(show) {
	if(show == "1")
		document.getElementById('generateAlbumUrl').style.display = 'block';
	else 
		document.getElementById('generateAlbumUrl').style.display = 'none';	
}

/*
 * To check the field is empy 
 */

 function isEmpty(elem, helperMsg){
	elem.value=trim(elem.value)
	if(elem.value.length == 0){
		displayErrorMessages(helperMsg);
		elem.focus(); // set the focus to this input
		//notDefined(); // set the border color
		return false;
  	}
	return true;
 }

/*
 * To check the field is Number of characters add 20091117
 */
 function isChar15(elem, helperMsg){
	elem.value=trim(elem.value)
	if(elem.value.length > 15){
		displayErrorMessages(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
  	}
	return true;
 }

 function isChar25(elem, helperMsg){
	elem.value=trim(elem.value)
	if(elem.value.length > 25){
		displayErrorMessages(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
  	}
	return true;
 }

 function isChar50(elem, helperMsg){
	elem.value=trim(elem.value)
	if(elem.value.length > 50){
		displayErrorMessages(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
  	}
	return true;
 }

 function isChar100(elem, helperMsg){
	elem.value=trim(elem.value)
	if(elem.value.length > 100){
		displayErrorMessages(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
  	}
	return true;
 }


 function isChar250(elem, helperMsg){
	elem.value=trim(elem.value)
	if(elem.value.length > 250){
		displayErrorMessages(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
  	}
	return true;
 }

/* Function to hide shown errors messages*/

 function hideErrorMessages(){
 	document.getElementById('error_message').style.display = "none";
 }

 
/*
 * To check the field value is numeric
 */

 function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
		return true;
 	}else{
		
		displayErrorMessages(helperMsg);
		elem.focus();
		return false;
	}
}

/*
 * To check the field value is alphabet
 */
function isAlphabet(elem, helperMsg){
	var alphaExp = /^[a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	 }else{
		displayErrorMessages(helperMsg);
		elem.focus();
		return false;
	}
}




/*
 * To check the field value is alphabet
 */
function isAlphabetWithSpace(elem, helperMsg){
	//var alphaExp = /^[a-zA-Z  + -]+$/;
	//var alphaExp = /^[a-zA-Z\s-]+$/;
	var alphaExp = /^\W+$/;
	//var alphaExp = /^[a-zA-Z0-9]+$/;
	//alert("'"+elem.value+"'");
	if(elem.value === "") {
		return true;
	 }
	if(elem.value.match(alphaExp)){

		return true;
	 }else{
		displayErrorMessages(helperMsg);
		elem.focus();
		return false;
	}
}


/*
 * To check the feild is alphanumeric
 */

function isAlphanumeric(elem, helperMsg){
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	 }else{ 
		displayErrorMessages(helperMsg);
		elem.focus();
		return false;
	}
}

/*
 * To check feild length
 */
/*
 * To check feild length
 */

function lengthRestriction(elem, min, max,helperMsg){

	var uInput = elem.value;
	if(uInput.length >= min && uInput.length <= max){
		return true;
	 }else{
	
		displayErrorMessages(helperMsg);
	
		elem.focus();
		return false;	
	}
}

/*
 * To check that the field is selected
 */

function madeSelection(elem, helperMsg){
	if(elem.value == "Please Choose"){
		displayErrorMessages(helperMsg);
		elem.focus();
		return false;
	}else{	
		return true;
	}
}

/*
 * To validate email address
 */

function emailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;	
	var email = trim(elem.value);
	if(email.match(emailExp)){	
		return true;
	 }else{
		displayErrorMessages(helperMsg);
		elem.focus();
		return false;
	}
}

/*
 * To check wether the two fields are equal or not
 */

function isEqual(elem1, elem2, helperMsg){	
	if(elem1.value === elem2.value){
		return true;
	}else{
		displayErrorMessages(helperMsg);
		elem1.focus();
		return false;
	}
}

 /*
 * radio button checked or not 
 */

 function radioChecked(elem,helperMsg) {
 	var radio_choice = false;
 	for(counter=0;counter<elem.length;counter++){
 		if(elem[counter].checked){
	 		radio_choice = true;
	 	}	 	
 	}
 	if(radio_choice) 	{
 		return true;
 	}else{
		displayErrorMessages(helperMsg);
		return false;
	}
 	
 }

 /*
 * Checkbox checked or not 
 */
 function checkboxChecked(elem,helperMsg) {
 	if(elem.checked){
 		return true;
 	}else{
 		displayErrorMessages(helperMsg);
		return false;
 	}
 }

 
 /*
 * Date of Birth validation 
 */

 function checkDOB(day,month,year,helperMsg)  {
 	var checkFlag = false;
 	var mydate= new Date();
 	var theYear = mydate.getUTCFullYear();
 	var thetoday = mydate.getUTCDate();
 	var theMonth = mydate.getUTCMonth()+ 1;
 	if( ( (month.value==4) || (month.value==6) || (month.value==9) || (month.value==11) ) && ( day.value > 30 ) ) {
  		checkFlag = true ;
  	}
  	if(month.value == 2) {
  		if((year.value%4) == 0)	{
  			if(day.value > 29)	{
  				checkFlag = true ;
  			}
  		}else{
  			if(day.value > 28)	{
  				checkFlag = true ;
  			}
  		}   	
 	}
 	if( (year.value == theYear) && ((month.value > theMonth)|| ((month.value >= theMonth)&& (day.value > thetoday) ) ))
 	{
 		checkFlag = true ;
 	}
    if(checkFlag){
  		displayErrorMessages(helperMsg);
  	}
  return checkFlag ;
 }
  
function isValidDateFormat(elem,helperMsg) {
	var dPat = /^(\d{4})(\-)(\d{1,2})(\-)(\d{1,2})$/;
	if(elem.value.match(dPat)){
		return true;
	 }else{
		displayErrorMessages(helperMsg);
		elem.focus();
		return false;
	}
}

function isValidDate(elem,helperMsg)  { 	
 	var checkFlag = false;
 	var dateArray = elem.value.split("-");
	var	year = dateArray[0];
	var	month = dateArray[1];
	var	day = dateArray[2];
  	if(month>12){
  		checkFlag = true ;
  	}  	
	if((year < 1900) || (month == 0) || (day == 0) ){
  		checkFlag = true ;
  	}
  	if(month == 2) {
  		if((year%4) == 0)	{
  			if(day > 29)	{
  				checkFlag = true ;
  			}
  		}else{
  			if(day > 28)	{
  				checkFlag = true ;
  			}
  		} 		
   	}
	else if( ( (month==4) || (month==6) || (month==9) || (month==11) ) && ( day > 30 ) ) {
  		checkFlag = true ;
  	}
	else if( ( (month==1) || (month==3) || (month==5) || (month==7) || (month==8) || (month==10)  || (month==12)) && ( day > 31 ) ) {
  		checkFlag = true ;
  	}

  	if(checkFlag){
  		displayErrorMessages(helperMsg);
  	}
	return checkFlag ;
 }
 	
function isFutureDate(elem, helperMsg){
	var curDate=new Date();
	var myDate=new Date();
	var dateArray = elem.value.split("-");
	var	year = dateArray[0];
	var	month = dateArray[1];
	var	day = dateArray[2];
	var month = month - 1;
	myDate.setFullYear( year, month, day );
	if (myDate > curDate){
		displayErrorMessages(helperMsg);
		elem.focus();
		return true;
	 }else{		
		return false;
	}
}
	



  /*
 * To validate Postal code
 */

function isValidPostalCode(elem, helperMsg){


	var numericExp = /^[0-9]{6}$/;
	
	
	if(elem.value.match(numericExp)){
	
		return true;
	 }else{ 
	
		displayErrorMessages(helperMsg);
		elem.focus();
		return false;
	 
	}
}


 /*
 * To validate Dob yyyy/mm/dd
 */

function isValidDob(elem, helperMsg){


	var dobExp = /^\d{4}\-\d{1,2}\-\d{1,2}$/;;
	
	
	if(elem.value.match(dobExp)){
	
		return true;
	 }else{ 
	
		displayErrorMessages(helperMsg);
		elem.focus();
		return false;
	
	}
}


/*
 * To validate minimum feild length 
 */

function validateMinLength(elem, min, hleperMsg){
	var uInput = elem.value;
	if(uInput.length >= min){	
		return true;
	 }else{	
		displayErrorMessages(hleperMsg);
		elem.focus();
		return false;	
	}
}




/*
 * To validate feild length 
 */

function validateLength(elem, max, hleperMsg){

	var uInput = elem.value;
	
	if(uInput.length <= max){
	
		return true;
	 }else{
	
		displayErrorMessages(hleperMsg);
		elem.focus();
		return false;
	
	}
}

/*
 * To check the feild is alphanumeric with underscore
 */

function isAlphanumericspace(elem, helperMsg){

	var alphaExp = /^[0-9a-zA-Z_]+$/;
	
	if(elem.value.match(alphaExp)){
	
		return true;
	 }else{ 
	
		displayErrorMessages(helperMsg);
		elem.focus();
		return false;
	 
	}
}



/*
 * To check the feild is alphanumeric with underscore
 */

function isAlphanumericspaceMenu(elem, helperMsg){

	var alphaExp = /^[0-9a-zA-Z_]+$/;
	
	if(elem.value.match(alphaExp)){
	
		return true;
	 }else{ 
	
		showErrorMessages(helperMsg);	
		elem.focus();
		return false;
	
	}
}

/*
 * To check wether the two fields are equal or not
 */

function isIdentical(elem1, elem2, helperMsg){	

	
	if(elem1.value === elem2.value){
	
		displayErrorMessages(helperMsg);
		elem1.focus();
		return true;
	
	}else{
	
		return false;
	
	}
}


/* 
 * Validate the image types for upload 
 */

function imageValidate(fldName, errorMsg) {
	if (!/(\.(gif|jpg|jpeg|bmp|png|tiff|tif))$/i.test(fldName.value)) {
		displayErrorMessages(errorMsg);
		fldName.focus();
		return false;
	}
	return true;
}



/* 
 * Validate the date format for dob
 */

function isValidDobFormat(fld, helperMsg) {
var dateStr = fld.value;
var datePat = /^\2(\d{4})(\-)(\d{1,2})(\-)(\d{1,2})$/;

if((dateStr.charAt(4) != "-") || (dateStr.charAt(7) != "-")){
	displayErrorMessages(helperMsg);
	return false;
}

var matchArray = dateStr.split('-');
month = matchArray[1];
day = matchArray[2];
year = matchArray[0];

if(month < 1 || month > 12) {
	displayErrorMessages(helperMsg);
	return false;
}

if (day < 1 || day > 31){
	displayErrorMessages(helperMsg);
	return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31){
	displayErrorMessages(helperMsg);
	return false
}
if (month == 2) {
	var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if ((day>29) || (day==29 && !isleap)) {
			displayErrorMessages(helperMsg);
			return false;
		}
}
return true;
}


function validatePhnum(phnum,helperMsg){
	var dPat = /^(\d{2}-\d{4}-\d{4})$/;
	if(phnum.value.match(dPat)){
		return true;	
	}else{
		displayErrorMessages(helperMsg);
		return false;
	}
	return false;
}

function validatefaxnum(phnum,helperMsg){
	var dPat = /^(\d{2}-\d{4}-\d{4})$/;
	if(phnum.value != "")
	{
		if(phnum.value.match(dPat)){
			return true;	
		}else{
			displayErrorMessages(helperMsg);
			return false;
		}
	}
	else
	{
		return true;
	}
	//return false;
}

function validatePhonenum(phnum,helperMsg){
	var phValue = phnum.value;

	if(phValue != "") {
		if(phValue.charAt(0) != 0) {
			displayErrorMessages(helperMsg);
			phnum.focus();
			return false;
		} else {
			if(phValue.length < 10) {
				displayErrorMessages(helperMsg);
				phnum.focus();
				return false;
			} else {
				var isNum = isNumeric(phnum, helperMsg);
				if(!isNum) {
					phnum.focus();
					return false;
				} else {
					return true;
				}
			}
		}
	} else {
		return true;
	}
}

/*function validatePostal(phnum,helperMsg){
	var dPat = /^(\d{3}-\d{4})$/;
	if(phnum.value.match(dPat)){
		return true;	
	}else{
		displayErrorMessages(helperMsg);
		return false;
	}
	return false;
}*/
function validatePostal1(phnum,helperMsg){
	var dPat = /^(\d{3})$/;
	if(phnum.value.match(dPat)){
		return true;	
	}else{
		displayErrorMessages(helperMsg);
		phnum.focus();
		return false;
	}
	return false;
}
function validatePostal2(phnum,helperMsg){
	var dPat = /^(\d{4})$/;
	if(phnum.value.match(dPat)){
		return true;	
	}else{
		displayErrorMessages(helperMsg);
		phnum.focus();
		return false;
	}
	return false;
}

/*
 * To check wether the two fields are equal or not case insensitive
 */
function isiIdentical(elem1, elem2, helperMsg){	

	
	if(elem1.value.toLowerCase() === elem2.value.toLowerCase()){
	
		displayErrorMessages(helperMsg);
		elem1.focus();
		return true;
	
	}else{
	
		return false;
	
	}
}

function validateCity(elem,helperMsg)
{
	if(elem.value.length > 0)
	{
		//var alphaExp = /^[a-zA-Z\s-]+$/;
		var alphaExp = /^\D+$/;		
		if(elem.value.match(alphaExp)){
			return true;
		 }else{
			displayErrorMessages(helperMsg);
			elem.focus();
			return false;
		}
	}
	else
	{
		return true;
	}
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function validatePrice(elem,helperMsg){
	var dPat =/^((0|[1-9]\d*)|(0|[1-9]\d*)(\.\d{1,2}))$/ ; 
	if(elem.value.match(dPat)){
		return true;	
	}else{
		displayErrorMessages(helperMsg);
		return false;
	}
	return false;
}

function validNumber(elem,helperMsg){
	if(elem.value > 0){
		return true;	
	}else{
		displayErrorMessages(helperMsg);
		return false;
	}
}



function generatePdf(url)
{
            window.open(url);
}


function goBack()
{
           window.history.back();
}

function goBackStepTwo()
{
           window.history.back(-1);
           window.history.back(-1);           
}


/*
 * To validate loyalti price for template
 */
function validateLoyaltyPrice(obj, helperMsg)
{
	if(obj.value.length != 0)
	{
		if(! validatePrice(obj, helperMsg))
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
		return true;
	}
}


/* function to validate the login form */
function validateSearchForm(obj){		
		if(!isSearchFieldEmpty(obj.query,msg_empty_query))  	
  			return false;
		else
			return true;		
	}
function showErrorMessages(msg){
 	var err_div  = document.getElementById('error_right_message');		
  	err_div.style.display = '';
	err_div.innerHTML = msg ;
}
/*
 * To check the field is empy 
*/
function isSearchFieldEmpty(elem, helperMsg){
	elem.value=trim(elem.value)
	if(elem.value.length == 0){
	 	var err_div  = document.getElementById('search_error_message');		
	  	err_div.style.display = '';
		err_div.innerHTML = helperMsg ;
		elem.focus(); // set the focus to this input
		return false;
  	}
	return true;
}
/*
 * To check the field is empy 
*/
function isFieldEmpty(elem, helperMsg){
	var val = trim(elem.value)
	if(val.length == 0){
		showErrorMessages(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
  	}
	return true;
}
/*
 * To check the feild is alphanumeric
 */

function isFieldAlphanumeric(elem, helperMsg){
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	 }else{ 
		showErrorMessages(helperMsg);
		elem.focus();
		return false;
	}
}

/*
 * To validate email address
 */

function isEmailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;	
	var email = trim(elem.value);
	if(email.match(emailExp)){	
		return true;
	 }else{
		showErrorMessages(helperMsg);
		elem.focus();
		return false;
	}
}

function loginFormValidation(obj){
	if(!isFieldEmpty(obj.username, msg_userid_error)) 
		return false;
		
	else if(!isAlphanumericspaceMenu(obj.username,msg_userid_error))
		return false;		
	
	else if(!isFieldEmpty(obj.pwd, msg_pwd_error)) 
		return false;	
//	else if(!isFieldAlphanumeric(obj.username, msg_login_error))
//		return false;
	else if(!isFieldAlphanumeric(obj.pwd, msg_login_error))
	{
		obj.username.value = '';
		obj.pwd.value = '';
		obj.username.focus();
		return false;	
	}
 	else
		return true;		
}


function checkValidPostalCode(shipping_postal1,shipping_postal2,shipping_nickname,address,uniqueaddress,helperMsg,helperMsg1){
	xmlHttp = GetXmlHttpObject();
	xmlHttp1 = GetXmlHttpObject();
 	//postcode = shipping_postal.value ; 
    postcode = shipping_postal1.value+shipping_postal2.value ; 
 	var nickname = shipping_nickname.value ; 
 	var url= address + "pcode/" + postcode ;
 	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
	
		var response = xmlHttp.responseText;
		var splitResult = response.split("-delimiter-");
		if( (splitResult[1] == "" ) &&  (splitResult[2] == "" ) && (splitResult[3] == "" ) && (splitResult[4] == "" ) )
		{
			displayErrorMessages(helperMsg);
			chkPostal = 0;
			return false;						
		}
		else
		{
			checkValidNickName(shipping_nickname,uniqueaddress,helperMsg1);
		}	
 }



function dateValidation(dateStr,helperMsg) {
	var datePat = /^\2(\d{4})(\-)(\d{1,2})(\-)(\d{1,2})$/;
	var i=7;
	if(dateStr.length == 9){
		
		i=6;
	
	}
	if((dateStr.charAt(4) != "-") || (dateStr.charAt(i) != "-")){
		
		displayErrorMessages(helperMsg);
		return false;
		
	}
	
	//var matchArray = dateStr.match(datePat); // is the format ok?
	var matchArray = dateStr.split('-');
	//alert(matchArray);
		
	month = matchArray[1];
	day = matchArray[2];
	year = matchArray[0];
	//alert(year);
	//alert(month);
	//alert(day);

	if (month < 1 || month > 12) { // check month range

	displayErrorMessages(helperMsg);
	return false;

	}
	if (day < 1 || day > 31) {

	displayErrorMessages(helperMsg);
	return false;

	}
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {

	displayErrorMessages(helperMsg);
	return false

	}
	if (month == 2) { // check for february 29th

	var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
	
		if (day>29 || (day==29 && !isleap)) {
	
	displayErrorMessages(helperMsg);
	return false;
	
	   }
	}

	return true;  // date is valid

	}



 function checkdiffDate(date1,date2,helperMsg){

 	var check = false;
  	var replacedateformat1 = date1.replace(/-/g,"/");
 	var replacedateformat2 = date2.replace(/-/g,"/");
 	var dateparsevalue1 = Date.parse(replacedateformat1);
 	var dateparsevalue2 = Date.parse(replacedateformat2);
 	
 	if(dateparsevalue2 >= dateparsevalue1){
 	
 	 		check = true;
 	
 	}
 	
 	
 	
 	if(check == false){
 	
  		displayErrorMessages(helperMsg);
  	
  	}
  	
	return check; 	

 }


function futuredateValidation(elem, helperMsg){
	var curDate=new Date();
	var myDate=new Date();
	var dateArray = elem.split("-");
	var	year = dateArray[0];
	var	month = dateArray[1];
	var	day = dateArray[2];
	var month = month - 1;
	myDate.setFullYear( year, month, day );
	if (myDate > curDate){
		displayErrorMessages(helperMsg);
		return false;
	 }else{		
		return true;
	}
} 



function isFloat(elem, helperMsg){
	var numericExpression = /^((\d+(\.\d*)?)|((\d*\.)?\d+))$/;
	if(elem.value.match(numericExpression)){
		return true;
	} else {
		displayErrorMessages(helperMsg);
		elem.focus();
		return false;
	}
}




function checkGreater(val1,val2,helperMsg){

	 var check = false;

	 if(parseFloat(val1.length)!=0 && parseFloat(val2.length)!=0)
			check=false;
		if(parseFloat(val1) <= parseFloat(val2)){

			return true;

	 	}

 	

 		if(check == false) {

  			displayErrorMessages(helperMsg);return false;

	  	}



}


function checkValidNickName(shipping_nickname,address,helperMsg){
	xmlHttp = GetXmlHttpObject();
 	var nickname = shipping_nickname.value ; 
 	var url= address + "shippingNickName/" + nickname ;
 	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
	
		var response = xmlHttp.responseText;
		if(response == 1)
		{
			displayErrorMessages(helperMsg);
			return false;						
		}
		else
		{
			chkPostal=1;
			return true;
		}	
 }

function scrollToTop(){

	scrollTo(0, 0);

}



 function displayErrorMessagesById(msg, id){
 	var err_div  = document.getElementById(id);		
  	err_div.style.display = 'block';
	err_div.innerHTML = msg ;
  }
  
   function hideErrorMessagesById(id){
 	document.getElementById(id).style.display = "none";
 }
 
 
 
 	function validQuantity(elem, divid, isNumberMsg, validNumberMsg, maxQtyLimitMsg)
 	{
		var numericExpression = /^[0-9]+$/;
		if(!(elem.value.match(numericExpression))){
			//displayErrorMessagesById(isNumberMsg, divid);
			showValidationMessage(isNumberMsg,elem.id);
			//elem.focus();
			return false;
		}
	 	if(!(parseInt(elem.value) > 0)){
				//displayErrorMessagesById(validNumberMsg, divid);
				showValidationMessage(validNumberMsg,elem.id);
				//elem.focus();
				return false;
		}
		if (parseInt(elem.value) > maxQuantityLimit )
		{
			//displayErrorMessagesById(maxQtyLimitMsg, divid);
			showValidationMessage(maxQtyLimitMsg,elem.id);
			//elem.focus();
			return false;
		}
		return true;
	}


function closeCartItem(slideid, imgid, hidid)
{
	var imgSrc = document.getElementById(imgid).src;
	if (document.getElementById(hidid).value == 0)
	{ 	
			slideid.start();
			//document.getElementById(cartid).style.display = 'none';
			document.getElementById(hidid).value = 1;
			imgSrc = imgSrc.replace('minus','plus');
	}		
	else
	{
			slideid.start();
			document.getElementById(hidid).value = 0;
			//document.getElementById(cartid).style.display = '';
			imgSrc = imgSrc.replace('plus','minus');
	}
	document.getElementById(imgid).src = imgSrc; 
}


/*
 * To check wether the element contains whitespace or not
 */
function hasWhiteSpace(elem1, helperMsg){	
	var alphaExp = /(\s)/ ;
	if(elem1.value.match(alphaExp)){
		displayErrorMessages(helperMsg);
		elem1.focus();
		return true;
	}
	else
	{  
		return false;
	}
}

 /*
 * To check wether the element is null or not
 */
 function isNull(elem, helperMsg){
	if(elem.value.length == 0){
		displayErrorMessages(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
  	}
	return true;
 }
 
 function confirmUnregister()
 {
  	var status = confirm (msg_confirm_unregister);
     if (status==false)
        	return false
    else
    		return true;    	
 
 }
function loadAvatarImage() {
	hm('browseAvatarImage');
}	
function unloadCancelOrder(omsNo){
	hm('browseCancelOrder');
	if(omsNo!=0)
	{
		var btncancelName = "btnCancelOrder"+omsNo;
		document.getElementById(btncancelName).style.display ='none';
	}
	
}
function deleteNewyear(baseUrl,pId){
	if(responseAction == 0) {
		responseAction = 1;
		window.location.href = baseUrl+"/products/Viewcart/delete-newyear/ajaxRemove/true/id/"+pId;
	}
}
/**
 * �J�[�g���폜����B���N��p
 */
function deleteNewyearin(baseUrl,pId){
	if(responseAction == 0) {
		responseAction = 1;
		window.location.href = baseUrl+"/products/Viewcart/delete-newyearin/ajaxRemove/true/id/"+pId;
	}
}
function deletePostcard(baseUrl,pId){
	if(responseAction == 0) {
		responseAction = 1;
		window.location.href = baseUrl+"/products/Viewcart/delete-postcard/ajaxRemove/true/id/"+pId;
	}
}

function deletePhotobook(baseUrl,pId){
	if(responseAction == 0) {
//		var req = Spry.Utils.loadURL("get",baseUrl+"/products/Viewcart/deletePhotobook/ajaxRemove/true/id/"+pId, true, deletePhotobookWindow);
		responseAction = 1;
		window.location.href = baseUrl+"/products/Viewcart/delete-photobook/ajaxRemove/true/id/"+pId;
	}
}
function deletePhotobookWindow(req) {
	Spry.Utils.setInnerHTML('deletePhotobookDiv', req.xhRequest.responseText);
	sm('deletePhotobookDiv',0,0);
}
function updatePhotobookCartDiv()
{
	hm('deletePhotobookDiv');
	Spry.Utils.submitForm('add_to_cart', updateResponseDiv ,{method:'post', additionalData:'ajaxSubmit=true&ptype=photobook'});
	responseAction = 0;
	//Spry.Utils.submitForm('add_to_cart', updateResponseDiv ,{method:'post', additionalData:'ajaxSubmit=true&ptype=photoprint'});
}
function deletePhotoprint(baseUrl,pId){
	sm('progressBarDiv',0,0);
	//var req = Spry.Utils.loadURL("get",baseUrl+"/products/Viewcart/deletePhotoprint/ajaxRemove/true/id/"+pId, true, deletePhotoprintWindow);
	window.location.href = baseUrl+"/products/Viewcart/delete-photoprint/ajaxRemove/true/id/"+pId;  
	
}
function deletePhotoprintWindow(req) {
	// Condition to check if session is expired. In case of focId is '0' it means that the session is expired.
	if(req.xhRequest.responseText.indexOf("focusNHideModal('0')")!=-1)
	{
		Spry.Utils.setInnerHTML('deletePhotoprintDiv', req.xhRequest.responseText);
		sm('deletePhotoprintDiv',0,0);
	}
	else
	{
		updatePhotoprintCartDiv();
	}
}
function clearPhotoprint(baseUrl){
	sm('progressBarDiv',0,0);
	//var req = Spry.Utils.loadURL("get",baseUrl+"/products/Viewcart/clearPhotoprint/ajaxClear/true/", true, clearPhotoprintWindow);
	window.location.href = baseUrl+"/products/Viewcart/clear-photoprint/ajaxClear/true/";  
}
function clearPhotoprintWindow(req) {
	Spry.Utils.setInnerHTML('clearPhotoprintDiv', req.xhRequest.responseText);
	sm('clearPhotoprintDiv',0,0);
	document.forms['add_to_cart'].cdnumbers.value = 1;
	document.forms['add_to_cart'].ordercd.checked = false;
	//document.forms['add_to_cart'].cdqty.value = 1;
}
function updatePhotoprintCartDiv()
{
	Spry.Utils.submitForm('add_to_cart', updateResponseDiv_Photoprint ,{method:'post', additionalData:'ajax=true&do=update'});
}

function clearNewyear(baseUrl){
//	sm('progressBarDiv',0,0);
	window.location.href = baseUrl+"/products/Viewcart/clear-newyear/ajaxClear/true/";  
}
function clearPostcard(baseUrl){
//	sm('progressBarDiv',0,0);
	window.location.href = baseUrl+"/products/Viewcart/clear-postcard/ajaxClear/true/";  
}

function cancelOrder(baseUrl,omsNo,orderid) {
	
	//alert(baseUrl+"/order/orderhistory/cancelOrder/orderid/"+omsNo+"/service_number/"+srNo+"/product_number/"+prNo+"/oms_number/"+omsNo);
//	var req = Spry.Utils.loadURL("get", baseUrl+"/order/orderhistory/cancelOrder/ajaxSubmit/true/oms_number/"+omsNo+"/order_id/"+orderid, true, showCancelOrderWindow);
	var req = Spry.Utils.loadURL("get", baseUrl+"/order/orderhistory/cancel-order/ajaxSubmit/true/oms_number/"+omsNo+"/order_id/"+orderid, true, showCancelOrderWindow);
}	
function showCancelOrderWindow(req) {
	Spry.Utils.setInnerHTML('resultCancelOrder', req.xhRequest.responseText);
}
function loadUrl()
{
//	resizePhotoPrintUpload(600,109);
	var photoprintForm = document.getElementById('myPhotoprintform');
	photoprintForm.submit();
	hm('uploadPhotoprint');
} 

function loadUrlPhotoPrintUpload()
{
	var ptMach = /Safari/;
	if((navigator.userAgent.match(ptMach)) && (navigator.appVersion.indexOf("Mac") == -1)){
		// Commenting bcoz of crash in safari / windows
		//changeColor();
	}
	resizePhotoPrintUpload(600,109);
	var photoprintForm = document.getElementById('myPhotoprintform');
	photoprintForm.action = baseUrl + "/products/Viewcart/index/servicecode/PP005";
	photoprintForm.submit();
	hm('uploadPhotoprint');
} 

function changeColor(){
	so.addParam("bgcolor","#FFFFFF");
	so.write("photoprintswf");
}

function closePhotoprint()
{
	var uploadPhotoprintdiv = document.getElementById('uploadPhotoprint');
	resizePhotoPrint(0,0);
	hm(uploadPhotoprintdiv);
}

function redirectUrl(formName, submitAction)
{
	document.getElementById(formName).action = submitAction;
	document.getElementById(formName).submit();
}

function turnOnOff(id, imgName, imgPath)
{ 
	id.src = imgPath+imgName;
}

function displayComments(albumId,isalbumImage,appHeight){
//	commentsArray.setURL(baseUrl+"/album/Comments/displayAlbumcomments/albumimageId/" + albumId + "/isalbumimage/"+ isalbumImage);
	commentsArray.setURL(baseUrl+"/album/Comments/display-albumcomments/albumimageId/" + albumId + "/isalbumimage/"+ isalbumImage);
	commentsArray.loadData();
	document.getElementById('comments').style.display = '';
	//document.getElementById('displayAlbum').style.height = appHeight;
	document.getElementById('flashcontent').style.height = appHeight;
	document.getElementById('comment_error_message').style.display = 'none';
}

/*
* This function unhide the comments and will hide comments confirmation screen div
*/
function unhideComments(){
	document.getElementById('comments').style.display = '';
	document.getElementById('comment_error_message').style.display = 'none';
}

/*
* This function hide the comments and comments confirmation screen div
*/
function hideComments(){
	document.getElementById('comments').style.display = 'none';
	document.getElementById('comment_error_message').style.display = 'none';
}

/*
* This function hide comments confirmation screen div
*/
function hideCommentsConfirmDiv(){
	document.getElementById('comment_error_message').style.display = 'none';
}

/*
* This function will resize the Application height and will hide the comments if hidecomments value is sent
*/
function resizeAlbum(appHeight,hidecomments){
	document.getElementById('flashcontent').style.height = appHeight;
	if(hidecomments == '')
		document.getElementById('comments').style.display = 'none';	
}

function isPrefectureEmpty(pref, helperMsg)
{
	
	if(pref.selectedIndex == 0)
	{
		displayErrorMessages(helperMsg);		
		return false;
	}
	
	return true;
}
/** Function to populate middle portion of products pages**/
var middleReq;
var middleTopText;
var topFlag = false;
/* Function to trigger Middle page population */
function triggerMiddle(middleURL) {
if (!topFlag)
{
	middleTopText = document.getElementById('mainarea').innerHTML;
	topFlag = true;
}
	middleReq = Spry.Utils.loadURL("get", baseUrl+"/static/"+middleURL, true, populateMiddle);
	return false;
}
/* Function to populat middle portion after fetching content from html file*/
function populateMiddle() {
	Spry.Utils.setInnerHTML('mainarea', middleReq.xhRequest.responseText);
}

/* Function to go back to first middle portion */
function returnToTopMiddle(){
	Spry.Utils.setInnerHTML('mainarea', middleTopText);
	topFlag=false;
}

/** Function will redirect to the specified url**/
function redirectPrevPage(url){
	window.location = url;
}

function truncate(trunc, len)
{	
	if (trunc.length > len) {
		trunc = trunc.substring(0, len);		
	}
	return trunc ;			
}
/*
* @Author: Ramesh Manne
* @Pupose: Display the Slide show of an Album using LyteBox
*/
function displaySlideShowWindow(req)
{
	moveToTop();
	Spry.Utils.setInnerHTML('imageslideshow', req.xhRequest.responseText);
	myLytebox.start(document.getElementById('frst'),true, false,document.getElementById('slideInterval').value);
}

/*
* @Author: Ramesh Manne
* @Pupose: Function will be triggered from Flex binary using external Interface call to load slideshow.
*/
function displaySlideShow(albumId){

	// Trianz - Slide show
	//var req = Spry.Utils.loadURL("get", baseUrl+"/album/Viewalbum/slideshow/id/" + albumId , true, displaySlideShowWindow);
	//alert('Slideshow Album ID ' + albumId);
	startLyteFrame(baseUrl+"/album/viewAlbum/slideshow/id/"+ albumId);
}

/*
* @Author: Ramesh Manne
* @Pupose: Fetch all the conf values
*/

function slideShowConfValues()
{
  this.labelImage = lbl_image;
  this.labelOf = lbl_of;
  this.labelSeconds = lbl_seconds;
  this.slideShowMinInterval = document.getElementById('slideMinInterval').value;
  this.slideShowMaxInterval = document.getElementById('slideMaxInterval').value;
}
function hideConfirmScreenModal(focId, redirUrl, baseUrl) {
	if(focId=='0')
	{
		window.location=baseUrl+"/products/"+redirUrl;
		hm();
	}
}

function resizePhotoPrint(width,height){
	document.getElementById('pswf').style.height = height + "px";//"700px";
	document.getElementById('pswf').style.width = width + "px";//"656px";	
	document.getElementById('photoprintalbumswf').style.height = height + "px";//"700px";
	document.getElementById('photoprintalbumswf').style.width = width + "px";//"656px";
	try {
		var pageDimension = pageSize()
		var obol=$('ol');
		obol.style.height = pageDimension[1]+'px' ;	
		obol.style.width  = pageDimension[0]+'px';	
	}catch (err) {
	
	}
}

function resizePhotoPrintUpload(width,height){
	document.getElementById('photoprintswf').style.height = height + "px";//"700px";
	document.getElementById('photoprintswf').style.width = width + "px";//"656px";
	try {
		var pageDimension = pageSize()
		var obol=$('ol');
		obol.style.height = pageDimension[1]+'px' ;	
		obol.style.width  = pageDimension[0]+'px';	
	}catch (err) {
	
	}
}

function hidePhotoPrint(){
	hm(document.getElementById('uploadPhotoprint'));
}

function commentsRedirectHomepage(){
	window.location =baseUrl+"/album/Viewalbum/";
}

function hideCommentErrorMessage(){
	document.getElementById('comment_error_message').style.display = 'none';
	document.getElementById('comment_error_message').innerHTML = '';
}

//*input border color add 20091203*/
//function notDefined(){
//	document.getElementById('surname').style.borderStyle='double';
//	document.getElementById('surname').style.borderColor='#ff8800';
//	document.getElementById('surname').style.backgroundColor='#fffcec';
//}
