﻿// JScript File

 function buildPrompt(caller,promptText) {	
 		// ERROR PROMPT CREATION AND DISPLAY WHEN AN ERROR OCCUR
 		var divFormError = document.createElement('div');
		var formErrorContent = document.createElement('div');
		var arrow = document.createElement('div');
		objcaller= document.getElementById(caller);
		
		$(divFormError).addClass("formError");
		$(divFormError).addClass($(objcaller).attr("name"));
		$(formErrorContent).addClass("formErrorContent");
		$(arrow).addClass("formErrorArrow");

		$("body").append(divFormError);
		$(divFormError).append(arrow);
		$(divFormError).append(formErrorContent);
		closingPrompt = $(objcaller).attr("name");
		
		$(arrow).html('<div style="text-align:left;top:-10px"><div class="line10"></div><div class="line9"></div><div class="line8"></div><div class="line7"></div><div class="line6"></div><div class="line5"></div><div class="line4"></div><div class="line3"></div><div class="line2"></div><div class="line1"></div></div>');
		promptText="<table width='100%' border='0'><tr><td valign='middle' width='90%'>"+promptText+"</td><td valign='top' width='10%'><img onclick=\"javascript:$('."+closingPrompt+"').remove();\" src='skins/skin_1/images/close2.gif' border='0' /></td><tr></table>";
		$(formErrorContent).html(promptText);
		
		callerTopPosition = $(objcaller).offset().top;
		callerleftPosition = $(objcaller).offset().left;
		callerWidth =  $(objcaller).width()
		callerHeight =  $(objcaller).height()
		errorcontentheight=$(".formErrorContent").height()
		
//		callerTopPosition = getRealTop(caller);
//		callerleftPosition = getRealLeft(caller);
//		callerWidth =  getElementWidth(caller);
//		callerHeight = getElementHeight(caller);
		//inputHeight = $(divFormError).height()
        //inputHeight = $("."+closingPrompt).height();
   
	
		//callerleftPosition = callerleftPosition + callerWidth -120;
		callerleftPosition = callerleftPosition + 10;
		callerTopPosition = callerTopPosition  -callerHeight -errorcontentheight-2;

		$(divFormError).css({
			top:callerTopPosition,
			left:callerleftPosition,
			zIndex: 100000,
			opacity:0
		})
		$(divFormError).fadeTo("fast",1);
		
	}

	function updatePromptText(caller,promptText) {	// UPDATE TEXT ERROR IF AN ERROR IS ALREADY DISPLAYED
		updateThisPrompt = caller;
		closingPrompt = document.getElementById(caller);
		promptText="<table width='100%' border='0'><tr><td valign='middle' width='90%'>"+promptText+"</td><td valign='top' width='10%'><img onclick=\"javascript:$('."+updateThisPrompt+"').remove();\" src='skins/skin_1/images/close2.gif' border='0' /></td><tr></table>";
		$("."+updateThisPrompt).find(".formErrorContent").html(promptText)
		
		callerTopPosition  = $(closingPrompt).offset().top;
		inputHeight = $("."+updateThisPrompt).height()
		
		callerTopPosition = callerTopPosition  -inputHeight -25
		$("."+updateThisPrompt).animate({
			top:callerTopPosition
		});
	}

function checkChkOutlogin()
{
    var Email=document.getElementById("EMail");
    var pass=document.getElementById("txtPassword");
    $(".formError").remove();
    if(isWhiteSpace(Email.value))
    {
       actElem='dupEmail';
       $(".formError").remove();
       promptText='Please enter valid Email Address';
       ($("."+actElem).size() ==0) ? buildPrompt('dupEmail',promptText): updatePromptText('dupEmail',promptText);
       document.getElementById("dupEmail").focus();
       return false;
    }
    if( !isProperEmail(Email.value))
    {
       actElem='EMail';
       $(".formError").remove();
       promptText='Please enter valid Email Address';
       ($("."+actElem).size() ==0) ? buildPrompt(actElem,promptText): updatePromptText(actElem,promptText);
       Email.focus();
       return false;
    }
    if(isWhiteSpace(pass.value))
    {
       actElem='dupPass';
       $(".formError").remove();
       promptText='Please enter Password';
       ($("."+actElem).size() ==0) ? buildPrompt(actElem,promptText)	: updatePromptText(actElem,promptText);
       pass.focus();
       return false;
    }
    return true;
}

function checkSkipRegEmail()
{
$(".formError").remove();
 if(isWhiteSpace(document.getElementById('txtSkipRegEmail').value))
    {
    
       actElem='txtSkipRegEmail';
       $(".formError").remove();
       promptText='Please enter your Email Address';
       ($("."+actElem).size() ==0) ? buildPrompt(actElem,promptText)	: updatePromptText(actElem,promptText);
       document.getElementById('txtSkipRegEmail').focus();
       return false;
    }
    if( !isProperEmail(document.getElementById('txtSkipRegEmail').value))
    {
       actElem='txtSkipRegEmail';
       $(".formError").remove();
       promptText='Please enter valid Email Address';
       ($("."+actElem).size() ==0) ? buildPrompt(actElem,promptText)	: updatePromptText(actElem,promptText);
       document.getElementById('txtSkipRegEmail').focus();
       return false;
    }
   $(".accorbilldiv").css({
			"display":"none"
		});
	$(".accorbilla").css({
			"display":"block"
		});
	$(".accorbilla").trigger("click");
	
    return true;
}

function popIt(elem,promptText)
{
   actElem=elem;
   $(".formError").remove();
   ($("."+actElem).size() ==0) ? buildPrompt(actElem,promptText)	: updatePromptText(actElem,promptText);
   document.getElementById(elem).focus();
}

function checkBillinginfo()
{
$(".formError").remove();
if(isWhiteSpace(document.getElementById('BillingFirstName').value))
 {
    popIt('BillingFirstName','Please enter the billing person first name');
    return false;
  }
if(isWhiteSpace(document.getElementById('BillingLastName').value))
 {
    popIt('BillingLastName','Please enter the billing person last name');
    return false;
  }
if(isWhiteSpace(document.getElementById('BillingPhone').value))
 {
    popIt('BillingPhone','Please enter the billing person phone');
    return false;
    }
if(isWhiteSpace(document.getElementById('BillingAddress1').value))
 {
    popIt('BillingAddress1','Please enter the billing address');
    return false;
    }
if(isWhiteSpace(document.getElementById('BillingCity').value))
 {
    popIt('BillingCity','Please enter the billing city');
    return false;
    }
if(isWhiteSpace(document.getElementById('BillingCountry').value))
 {
    popIt('BillingCountry','Please select the billing country');
    return false;
    }
if(isWhiteSpace(document.getElementById('BillingState').value))
 {
    popIt('BillingState','Please select the billing state');
    return false;
    }
if( isWhiteSpace(document.getElementById('BillingZip').value) )
 { 
    popIt('BillingZip','Please enter the billing zipcode');
    return false;
    }
    $(".accorshipdiv").css({
			"display":"none"
		});
	$(".accorshipa").css({
			"display":"block"
		});
	$(".accorshipa").trigger("click");
 return true;
}

function checkShippinginfo()
{
$(".formError").remove();
if(isWhiteSpace(document.getElementById('ShippingFirstName').value))
 {
    popIt('ShippingFirstName','Please enter the shipping first name');
    return false;
  }
if(isWhiteSpace(document.getElementById('ShippingLastName').value))
 {
    popIt('ShippingLastName','Please enter the Shipping person last name');
    return false;
  }
if(isWhiteSpace(document.getElementById('ShippingPhone').value))
 {
    popIt('ShippingPhone','Please enter the Shipping person phone');
    return false;
    }
if(isWhiteSpace(document.getElementById('ShippingAddress1').value))
 {
    popIt('ShippingAddress1','Please enter the Shipping address');
    return false;
    }
if(isWhiteSpace(document.getElementById('ShippingCity').value))
 {
    popIt('ShippingCity','Please enter the Shipping city');
    return false;
    }
if(isWhiteSpace(document.getElementById('ShippingCountry').value))
 {
    popIt('ShippingCountry','Please select the Shipping country');
    return false;
    }
if(isWhiteSpace(document.getElementById('ShippingState').value))
 {
    popIt('ShippingState','Please select the Shipping state');
    return false;
    }
if( isWhiteSpace(document.getElementById('ShippingZip').value) )
 { 
    popIt('ShippingZip','Please enter the Shipping zipcode');
    return false;
    }
 return true;
}

function checkshippingoption()
{
    $(".accorshipOptdiv").css({
			"display":"none"
		});
	$(".accorshipOpta").css({
			"display":"block"
		});
	$(".accorshipOpta").trigger("click");
}

function openallaccor()
{
  $(".accorbilldiv").css({
			"display":"none"
		});
	$(".accorbilla").css({
			"display":"block"
		});
	 $(".accorshipdiv").css({
			"display":"none"
		});
	$(".accorshipa").css({
			"display":"block"
		});
	$(".accorpaydiv").css({
			"display":"none"
		});
	$(".accorpaya").css({
			"display":"block"
		});
	$(".accorpaya").trigger("click");
}

function checkCreateACinfo()
{

$(".formError").remove();

if(isWhiteSpace(document.getElementById('FirstName').value))
 {
    popIt('FirstName','Please enter your first name');
    return false;
  }
if(isWhiteSpace(document.getElementById('LastName').value))
 {
    popIt('LastName','Please enter your last name');
    return false;
  }
 if(isWhiteSpace(document.getElementById('EMail').value))
    {
     popIt('EMail','Please enter your Email Address');
        return false;
    }
    if( !isProperEmail(document.getElementById('EMail').value))
    {
     popIt('EMail','Please enter valid Email Address');
        return false; 
    }
 if(isWhiteSpace(document.getElementById('Phone').value))
    {
     popIt('Phone','Please enter your Phone');
        return false;
    }
    if(document.getElementById('txtpassword').value=='')
     {
     popIt('txtpassword','Please enter Password');
     return false;
     }
     if(document.getElementById('txtpassword').value.length < 5)
     {
     popIt('txtpassword','Please enter at least 5 characters');
     return false;
     }
	if(document.getElementById('txtpassword2').value=='')
     {
     popIt('txtpassword2','Please enter confirm Password');
        return false;
     }
     if(document.getElementById('txtpassword2').value!=document.getElementById('txtpassword').value)
     {
     popIt('txtpassword2','Password and confirm Password do not match');
        return false;
     }
$(".accorbilldiv").css({
			"display":"none"
		});
	$(".accorbilla").css({
			"display":"block"
		});
	$(".accorbilla").trigger("click");
return true;
}

function checkCreateBillinginfo()
{
$(".formError").remove();
if(isWhiteSpace(document.getElementById('BillingFirstName').value))
 {
    popIt('BillingFirstName','Please enter the billing person first name');
    return false;
  }
if(isWhiteSpace(document.getElementById('BillingLastName').value))
 {
    popIt('BillingLastName','Please enter the billing person last name');
    return false;
  }
if(isWhiteSpace(document.getElementById('BillingPhone').value))
 {
    popIt('BillingPhone','Please enter the billing person phone');
    return false;
    }
if(isWhiteSpace(document.getElementById('BillingAddress1').value))
 {
    popIt('BillingAddress1','Please enter the billing address');
    return false;
    }
if(isWhiteSpace(document.getElementById('BillingCity').value))
 {
    popIt('BillingCity','Please enter the billing city');
    return false;
    }
if(isWhiteSpace(document.getElementById('BillingCountry').value))
 {
    popIt('BillingCountry','Please select the billing country');
    return false;
    }
if(isWhiteSpace(document.getElementById('BillingState').value))
 {
    popIt('BillingState','Please select the billing state');
    return false;
    }
if( isWhiteSpace(document.getElementById('BillingZip').value) )
 { 
    popIt('BillingZip','Please enter the billing zipcode');
    return false;
    }

$(".accorshipdiv").css({
			"display":"none"
		});
	$(".accorshipa").css({
			"display":"block"
		});
	$(".accorshipa").trigger("click");
return true;
}

function checkCreateShippinginfo()
{
$(".formError").remove();
if(isWhiteSpace(document.getElementById('ShippingFirstName').value))
 {
    popIt('ShippingFirstName','Please enter the shipping first name');
    return false;
  }
if(isWhiteSpace(document.getElementById('ShippingLastName').value))
 {
    popIt('ShippingLastName','Please enter the shipping person last name');
    return false;
  }
if(isWhiteSpace(document.getElementById('ShippingPhone').value))
 {
    popIt('ShippingPhone','Please enter the shipping person phone');
    return false;
    }
if(isWhiteSpace(document.getElementById('ShippingAddress1').value))
 {
    popIt('ShippingAddress1','Please enter the shipping address');
    return false;
    }
if(isWhiteSpace(document.getElementById('ShippingCity').value))
 {
    popIt('ShippingCity','Please enter the shipping city');
    return false;
    }
if(isWhiteSpace(document.getElementById('ShippingCountry').value))
 {
    popIt('ShippingCountry','Please select the shipping country');
    return false;
    }
if(isWhiteSpace(document.getElementById('ShippingState').value))
 {
    popIt('ShippingState','Please select the shipping state');
    return false;
    }
if( isWhiteSpace(document.getElementById('ShippingZip').value) )
 { 
    popIt('ShippingZip','Please enter the shipping zipcode');
    return false;
    }
return true;
}



function checkacinfo()
{
$(".formError").remove();
if(isWhiteSpace(document.getElementById('FirstName').value))
 {
    popIt('FirstName','Please enter your first name');
    return false;
  }
if(isWhiteSpace(document.getElementById('LastName').value))
 {
    popIt('LastName','Please enter your last name');
    return false;
  }
  if(isWhiteSpace(document.getElementById('EMail').value))
 {
    popIt('EMail','Please enter your E-mail');
    return false;
  }
if(isWhiteSpace(document.getElementById('Phone').value))
 {
    popIt('Phone','Please enter the phone');
    return false;
    }
    return true;
}


function checklogin()
{
if(isWhiteSpace(document.getElementById('EMail').value))
    {
     popIt('EMail','Please enter your Email Address');
        return false;
    }
    if( !isProperEmail(document.getElementById('EMail').value))
    {
     popIt('EMail','Please enter valid Email Address');
        return false; 
    }
    if(isWhiteSpace(document.getElementById('txtPassword').value))
 {
    popIt('txtPassword','Please enter your password');
    return false;
    }
    return true;
}


function openPayInfo()
{
$(".accorpaydiv").css({
			"display":"none"
		});
	$(".accorpaya").css({
			"display":"block"
		});
	$(".accorpaya").trigger("click");
	return false;
}