// JavaScript Document
function __fncSelectedCatg(CatId,CatName,CatoptId){
	$('hidCatId').value 		= CatId;
	$('hidCatName').value 		= CatName;
	$('hidCatoptId').value 		= CatoptId;
	$('hidhotPrdId').value 		= '';
	thisForm.submit();
}

function __fncSubCategorySelec(PcId,PcName){
	$('hidPrdCatId').value 		= PcId;
	$('hidPrdCatName').value 	= PcName;
	thisForm.txtWhat2Do.value='PRODUCTLIST';
	thisForm.submit();
}

function __fncProductSelec(PrId){
	$('hidPrdId').value 		= PrId;
	/*$('hidPrdpptid').value 		= poid;*/
	thisForm.txtWhat2Do.value='PRODUCTDETAILS';
	thisForm.submit();
}

function __fncHotDealProductSelec(PrId,poid){
	$('hidhotPrdId').value 		= PrId;
	$('hidPrdpptid').value 		= poid;
	thisForm.txtWhat2Do.value='PRODUCTDETAILS';
	thisForm.submit();
}

function __fncAddtoorder(PrId,PrdPrice,poid){
	$('hidPrdId').value 		= PrId;
	$('hidPrdPrice').value 		= PrdPrice;
	$('hidPrdpptid').value 		= poid;
	thisForm.txtWhat2Do.value='ADDTOCART';
	thisForm.action='addtocart.php';
	thisForm.submit();
}

function __fncDelete(cnt,Id){
	$('hidtotprice'+cnt).value='';
	$('hidId').value=Id;
	thisForm.txtWhat2Do.value='DELETE';
	thisForm.submit();
}
function __fncCheckout(){
	if($('hidtotCount').value==0){
		alert('Your cart is empty');
		return false;
	}
	$('hidship').value=$('divdelTotal').innerHTML;
	var str=$('divTotal').innerHTML;
	var cnt=str.split(',');
	var amt='';
	if(cnt.length>0){
		for(var i=0; i<cnt.length;i++){
			amt +=cnt[i];
			
		}	
	}else{
		amt =str;
	}
	$('hidtot').value=amt;
	thisForm.txtWhat2Do.value='CHECKOUT';
	thisForm.submit();
	return false;
	
}
function __fncPaypalCheckoutPaypal(){
	if($('hidtotCount').value==0){
		alert('Your cart is empty');
		return false;
	}
	$('hidship').value=$('divdelTotal').innerHTML;
	var str=$('divTotal').innerHTML;
	var cnt=str.split(',');
	var amt='';
	if(cnt.length>0){
		for(var i=0; i<cnt.length;i++){
			amt +=cnt[i];
			
		}	
	}else{
		amt =str;
	}
	$('hidtot').value=amt;
	thisForm.txtWhat2Do.value='PAYPALCHECKOUT';
	thisForm.submit();
	return false;
}
function __fncContinueShopping(){
	thisForm.action='shop.php';
	thisForm.submit();
}
/*####################################################################################################*/
function ShowDropDownMenuColor(count)
{
	if ($('popup_container_color').style.display == 'block')
	{
		for (passVariable = 1; passVariable <= count ; passVariable++)
		{
			$('drop_down_color'+passVariable).style.display = 'none';			
		}
		$('popup_container_color').style.display = 'none';
	}
	else
	{
		for (passVariable = 1; passVariable <= count ; passVariable++)
		{
			$('drop_down_color'+passVariable).style.display = 'block';
		}
		$('popup_container_color').style.display = 'block';
		/*$('err_hid_venu_id').style.visibility = 'hidden';*/
	}
}
function SetSelectedValueColor(thisVar,CrId,totalCount)
{
	ShowDropDownMenuColor(totalCount);
	if($('selected_option_color').innerHTML=='select colour'){
		$('selected_option_color').innerHTML = thisVar.innerHTML;
		$('hid_cr_id').value = '';
		$('hid_sz_id').value = '';
	}else{
		$('selected_option_color').innerHTML = thisVar.innerHTML;
		$('hid_cr_id').value = CrId;
		$('hid_sz_id').value = '';
	}
	thisForm.txtWhat2Do.value='PRODUCTDETAILS';
	thisForm.submit();
}

function changeOptionColor(thisVar,CrId)
{
		thisVar.className='active_colour_list';
		$('selected_option_color').innerHTML = thisVar.innerHTML;
		$('hid_cr_id').value = CrId;
	
	
}

/*####################################################################################################*/


function ShowDropDownMenuSize(count)
{
	if ($('popup_container_size').style.display == 'block')
	{
		if($('selected_option_color').innerHTML!='select colour'){
			for (passVariable = 1; passVariable <= count ; passVariable++)
			{
				$('drop_down_size'+passVariable).style.display = 'none';			
			}
			$('popup_container_size').style.display = 'none';
		}
	}
	else
	{
		if($('selected_option_color').innerHTML!='select colour'){
			for (passVariable = 1; passVariable <= count ; passVariable++)
			{
				$('drop_down_size'+passVariable).style.display = 'block';
			}
			$('popup_container_size').style.display = 'block';
			/*$('err_hid_venu_id').style.visibility = 'hidden';*/
		}
	}
}
function SetSelectedValueSize(thisVar,SzId,totalCount)
{
	if($('selected_option_color').innerHTML!='select colour'){
		ShowDropDownMenuSize(totalCount);
		$('selected_option_size').innerHTML = thisVar.innerHTML;
		$('hid_sz_id').value = SzId;
		$('hidPrdPrice').value	=	" ";
		thisForm.txtWhat2Do.value='PRODUCTDETAILS';
		thisForm.submit();
	}
}

function changeOptionSize(thisVar,SzId)
{
	if($('selected_option_color').innerHTML!='select colour'){
		thisVar.className='active_colour_list';
		$('selected_option_size').innerHTML = thisVar.innerHTML;
		$('hid_sz_id').value = SzId;
	}
}
/*####################################################################################################*/
function __fanSubmitOrder(){
//var a=thisForm.txtcvc.value;
 /* if(isCreditCard(thisForm.txtardnumber)==false){
  alert('Invalid Card Number');
	return;
  }*/
  
  if(($('txtardnumber').value.length < 16) ||($('txtardnumber').value.length > 16)){
	alert('Please Enter Valid Card number');
  	$('txtardnumber').select();
	return;  
  }
  if(thisForm.txtcvc.value ==''){
  alert('Enter CVC Code');
  thisForm.txtcvc.focus();
	return;
  }
  if(thisForm.txtcvc.value.length!=3){
  alert('Only 3 digits Allowed ');
  thisForm.txtcvc.focus();
	return;
  }
  if(isNaN(thisForm.txtcvc.value)) {						 
	alert('Please Enter Valid CVC Code'); 
	thisForm.txtcvc.select();return;
  }
//  val	=	$('txtardnumber').value;
//  value = val.substr( val.length - 3);
//  var inp =  value;
//  var outp = '';
//  for (i = 0; i < inp.length; i++) {
//    outp = inp.charAt(i)+ outp
//  }
//  if($('txtcvc').value != outp)
//  {
//	 alert('Please Enter Valid CVC Code');
//	 $('txtcvc').select();
//	 return;
//  }
//  if(thisForm.txtgrndtot.value < 6){
//  alert('Your Cart is Empty');
//	return;
//  }
  thisForm.txtWhat2Do.value = 'SAVEORDERDETAILS';
  thisForm.submit();
}
function __showsipp(){
	if(document.getElementById('samechk').checked == true ){
		document.getElementById('AddressDiv').style.display='block';
		document.getElementById('txtAddresD').style.display='block';
		//document.getElementById('txtShipp').value = document.getElementById('txtBill').value
	}
	else{
	document.getElementById('txtAddresD').style.display='none';
	}
}
function isCreditCard(textObj) {
   var ccNum;
   var odd = 1;
   var even = 2;
   var calcCard = 0;
   var calcs = 0;
   var ccNum2 = "";
   var aChar = '';
   var cc;
   var r;
   
   ccNum = textObj.value;
   for(var i = 0; i != ccNum.length; i++) {
	  aChar = ccNum.substring(i,i+1);
	  if(aChar == '-') {
		 continue;
	  }

	  ccNum2 = ccNum2 + aChar;
   }
   cc = parseInt(ccNum2);
   if(cc == 0) {
	  return false;
   }
   r = ccNum.length / 2;
   if(ccNum.length - (parseInt(r)*2) == 0) {
	  odd = 2;
	  even = 1;
   }
   
   for(var x = ccNum.length - 1; x > 0; x--) {
	  r = x / 2;
	  if(r < 1) {
		 r++;
	  }
	  if(x - (parseInt(r) * 2) != 0) {
		 calcs = (parseInt(ccNum.charAt(x - 1))) * odd;
	  }
	  else {
		 calcs = (parseInt(ccNum.charAt(x - 1))) * even;
	  }
	  if(calcs >= 10) {
		 calcs = calcs - 10 + 1;
	  }
	  calcCard = calcCard + calcs;
   }
   
   calcs = 10 - (calcCard % 10);
   if(calcs == 10) {
	  calcs = 0;
   }
   
   if(calcs == (parseInt(ccNum.charAt(ccNum.length - 1)))) {
	  return true;
   }
   else {
	  return false;
   }
}
/*#################################################################################################################*/
function __fncAddtoorderGV(GvId,GvPrice){
	$('hidGvid').value 		= GvId;
	$('hidGvprice').value 	= GvPrice;
	thisForm.txtWhat2Do.value='ADDGVTOCART';
	thisForm.action='giftvouchure.php';
	thisForm.submit();
}
function __fncGVSelec(GvId){
	$('hidGvid').value 		= GvId;
	thisForm.txtWhat2Do.value='GVDETAILS';
	thisForm.submit();
}
/*##################################################################################################################*/
function makePOSTRequest(url, parameters) {
		http_request = false;
		if (window.XMLHttpRequest) { // Mozilla, Safari,...
			http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType) {
				http_request.overrideMimeType('text/html');
			}
		} else if (window.ActiveXObject) { // IE
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		if (!http_request) {
			alert('Cannot create XMLHTTP instance');
			return false;
		}
		http_request.onreadystatechange = alertContentsdetails;
		http_request.open('POST', url, true);
		http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http_request.setRequestHeader("Content-length", parameters.length);
		http_request.setRequestHeader("Connection", "close");
		http_request.send(parameters);
	}
function alertContentsdetails() {
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				
				result = http_request.responseText;
				/*document.getElementById('img').innerHTML = result;  */
								
			} else {
				document.getElementById('myspan').innerHTML = 'There was a problem with the request.';  
			}
		}
	}
function __fncIncrement(num,price,vat,delchr,delprice,delid) {
	var subtot=0;
	var finaltot=0;
	var vatamt=0;
	var delchrg='';
	if(price==0){
		subtot='00.00';	
	}
	var qty=parseFloat(parseFloat($('divQty'+num).innerHTML)+parseFloat(1));
	tot= round_decimals((parseFloat(parseFloat(qty)*parseFloat(price))),2);
	$('divQty'+num).innerHTML= qty;
	$('divtot'+num).innerHTML=tot;
	$('hidQty'+num).value=qty;
	$('hidtotprice'+num).value=tot;
	for(var i=0;i<$('hidtotCount').value;i++){
		subtot = round_decimals(parseFloat(parseFloat(subtot)+parseFloat($('divtot'+i).innerHTML)),2);
	}
	finaltot=parseFloat(parseFloat(finaltot)+parseFloat(subtot));
	for(var j=0;j<$('hidtotCount').value;j++){
		 vatamt=round_decimals(parseFloat(parseFloat(vatamt)+parseFloat(parseFloat($('divQty'+j).innerHTML)*parseFloat($('hidvat'+j).value))),2);
	}
	finaltot =parseFloat(parseFloat(finaltot)+parseFloat(vatamt));
	if(delid==1){
		if(parseInt(finaltot) < parseInt(delprice)){
			finaltot =parseFloat(parseFloat(finaltot)+parseFloat(delchr));
			delchrg=round_decimals(parseFloat(delchr),2);
		}else{
			delchrg="0.00";
		}
	}else{
		finaltot =parseFloat(parseFloat(finaltot)+parseFloat(delchr));
		delchrg=round_decimals(parseFloat(delchr),2);
	}
	finaltot =round_decimals(parseFloat(finaltot),2);
	$('divSubTotal').innerHTML=subtot;
	$('divVatTotal').innerHTML=vatamt;
	$('divdelTotal').innerHTML=delchrg;
	$('divTotal').innerHTML=finaltot;
	$('hidtot').value=finaltot;
	var okSoFar=true
		document.getElementById('myspan').innerHTML = '';  
		var poststr = "qty=" + encodeURI(qty)
		+"&tot="+ encodeURI(tot)
		+"&cdid="+ encodeURI(document.getElementById('hidCdId'+num).value);
		makePOSTRequest('updatecart.php?action=updatecart', poststr);
}
function __fncDecrement(num,price,vat,delchr,delprice,delid){
	var subtot=0;
	var finaltot=0;
	var vatamt=0;
	var delchrg='';
	if(price==0){
		subtot='00.00';	
	}
	if($('divQty'+num).innerHTML>1){
		var qty=parseFloat(parseFloat($('divQty'+num).innerHTML)-parseFloat(1));
		tot= round_decimals((parseFloat(parseFloat(qty)*parseFloat(price))),2);
		$('divQty'+num).innerHTML= qty;
		$('divtot'+num).innerHTML=tot;
		$('hidQty'+num).value=qty;
		
	$('hidtotprice'+num).value=tot;
		for(var i=0;i<$('hidtotCount').value;i++){
			subtot = round_decimals(parseFloat(parseFloat(subtot)+parseFloat($('divtot'+i).innerHTML)),2);
		}
		finaltot=parseFloat(parseFloat(finaltot)+parseFloat(subtot));
		for(var j=0;j<$('hidtotCount').value;j++){
		 vatamt=round_decimals(parseFloat(parseFloat(vatamt)+parseFloat(parseFloat($('divQty'+j).innerHTML)*parseFloat($('hidvat'+j).value))),2);
		}
		
		finaltot =parseFloat(parseFloat(finaltot)+parseFloat(vatamt));
		if(delid==1){
			if(parseInt(finaltot) < parseInt(delprice)){
				finaltot =parseFloat(parseFloat(finaltot)+parseFloat(delchr));
				delchrg=round_decimals(parseFloat(delchr),2);
			}else{
				delchrg="0.00";
			}
		}else{
			finaltot =parseFloat(parseFloat(finaltot)+parseFloat(delchr));
			delchrg=round_decimals(parseFloat(delchr),2);
		}
		finaltot =round_decimals(parseFloat(finaltot),2);
		$('divSubTotal').innerHTML=subtot;
		$('divVatTotal').innerHTML=vatamt;
		$('divdelTotal').innerHTML=delchrg;
		$('divTotal').innerHTML=finaltot;
		$('hidtot').value=finaltot;
		var okSoFar=true
		document.getElementById('myspan').innerHTML = '';  
		var poststr = "qty=" + encodeURI(qty)
		+"&tot="+ encodeURI(tot)
		+"&cdid="+ encodeURI(document.getElementById('hidCdId'+num).value);
		makePOSTRequest('updatecart.php?action=updatecart', poststr);
	}
}

/*##################################################################################################################*/

function get2(obj) {
	var okSoFar=true
	//var foundAt = document.phpformmailer.txtemail.value.indexOf("@",0)
	if(document.getElementById("txtAddresD").value =="Please enter the delivery address here"){
	document.getElementById("txtAddresD").value = '';}
	document.getElementById("txtAddresD").style.color = '#01ABE9';
	var poststr = "txtAddresD=" + encodeURI( document.getElementById("txtAddresD").value );
	//makePOSTRequest1('post.php', poststr);
}
/*#################################################################################################################*/
function ShowDropDownMenuCard(count)
{
	if ($('popup_container').style.display == 'block')
	{
		for (passVariable = 1; passVariable <= count ; passVariable++)
		{
			$('drop_down'+passVariable).style.display = 'none';			
		}
		$('popup_container').style.display = 'none';
	}
	else
	{
		for (passVariable = 1; passVariable <= count ; passVariable++)
		{
			$('drop_down'+passVariable).style.display = 'block';
		}
		$('popup_container').style.display = 'block';
		//$('err_hid_venu_id').style.visibility = 'hidden';
	}
}
function SetSelectedValueCard(thisVar,CategoryId,totalCount)
{
	ShowDropDownMenuCard(totalCount);
	$('selected_option').innerHTML = thisVar.innerHTML;
	$('hid_card_id').value = CategoryId;
}

function changeOptionCard(thisVar,CategoryId)
{
	thisVar.className='active_thank_card_list';
	$('selected_option').innerHTML = thisVar.innerHTML;
	$('hid_card_id').value = CategoryId;
}
/*#################################################################################################################*/
function ShowDropDownMenuStartMonth(count)
{
	if ($('popup_container_month').style.display == 'block')
	{
		for (passVariable = 1; passVariable <= count ; passVariable++)
		{
			$('drop_down'+passVariable).style.display = 'none';			
		}
		$('popup_container_month').style.display = 'none';
	}
	else
	{
		for (passVariable = 1; passVariable <= count ; passVariable++)
		{
			$('drop_down'+passVariable).style.display = 'block';
		}
		$('popup_container_month').style.display = 'block';
		//$('err_hid_venu_id').style.visibility = 'hidden';
	}
}
function SetSelectedValueStartMonth(thisVar,CategoryId,totalCount)
{
	ShowDropDownMenuStartMonth(totalCount);
	$('selected_option_start_month').innerHTML = thisVar.innerHTML;
	$('hid_start_month').value = CategoryId;
}

function changeOptionStartMonth(thisVar,CategoryId)
{
	thisVar.className='active_thank_card_list';
	$('selected_option_start_month').innerHTML = thisVar.innerHTML;
	$('hid_start_month').value = CategoryId;
}
/*#################################################################################################################*/
function ShowDropDownMenuStartYear(count)
{
	if ($('popup_container_Year').style.display == 'block')
	{
		for (passVariable = 1; passVariable <= count ; passVariable++)
		{
			$('drop_down'+passVariable).style.display = 'none';			
		}
		$('popup_container_Year').style.display = 'none';
	}
	else
	{
		for (passVariable = 1; passVariable <= count ; passVariable++)
		{
			$('drop_down'+passVariable).style.display = 'block';
		}
		$('popup_container_Year').style.display = 'block';
		//$('err_hid_venu_id').style.visibility = 'hidden';
	}
}
function SetSelectedValueStartYear(thisVar,CategoryId,totalCount)
{
	ShowDropDownMenuStartYear(totalCount);
	$('selected_option_start_Year').innerHTML = thisVar.innerHTML;
	$('hid_start_Year').value = CategoryId;
}

function changeOptionStartYear(thisVar,CategoryId)
{
	thisVar.className='active_thank_card_list';
	$('selected_option_start_Year').innerHTML = thisVar.innerHTML;
	$('hid_start_Year').value = CategoryId;
}
/*#################################################################################################################*/
function ShowDropDownMenuexpMonth(count)
{
	if ($('popup_container_exp_month').style.display == 'block')
	{
		for (passVariable = 1; passVariable <= count ; passVariable++)
		{
			$('drop_down'+passVariable).style.display = 'none';			
		}
		$('popup_container_exp_month').style.display = 'none';
	}
	else
	{
		for (passVariable = 1; passVariable <= count ; passVariable++)
		{
			$('drop_down'+passVariable).style.display = 'block';
		}
		$('popup_container_exp_month').style.display = 'block';
		//$('err_hid_venu_id').style.visibility = 'hidden';
	}
}
function SetSelectedValueexpMonth(thisVar,CategoryId,totalCount)
{
	ShowDropDownMenuexpMonth(totalCount);
	$('selected_option_exp_month').innerHTML = thisVar.innerHTML;
	$('hid_exp_month').value = CategoryId;
}

function changeOptionexpMonth(thisVar,CategoryId)
{
	thisVar.className='active_thank_card_list';
	$('selected_option_exp_month').innerHTML = thisVar.innerHTML;
	$('hid_exp_month').value = CategoryId;
}
/*#################################################################################################################*/
function ShowDropDownMenuexpYear(count)
{
	if ($('popup_container_exp_Year').style.display == 'block')
	{
		for (passVariable = 1; passVariable <= count ; passVariable++)
		{
			$('drop_down'+passVariable).style.display = 'none';			
		}
		$('popup_container_exp_Year').style.display = 'none';
	}
	else
	{
		for (passVariable = 1; passVariable <= count ; passVariable++)
		{
			$('drop_down'+passVariable).style.display = 'block';
		}
		$('popup_container_exp_Year').style.display = 'block';
		//$('err_hid_venu_id').style.visibility = 'hidden';
	}
}
function SetSelectedValueexpYear(thisVar,CategoryId,totalCount)
{
	ShowDropDownMenuexpYear(totalCount);
	$('selected_option_exp_Year').innerHTML = thisVar.innerHTML;
	$('hid_exp_Year').value = CategoryId;
}

function changeOptionexpYear(thisVar,CategoryId)
{
	thisVar.className='active_thank_card_list';
	$('selected_option_exp_Year').innerHTML = thisVar.innerHTML;
	$('hid_exp_Year').value = CategoryId;
}
function __fncBackSubCatg(CatId){
	$('hidCatId').value 		= CatId;
	$('hidPrdCatId').value 		='';
	thisForm.txtWhat2Do.value='';
	thisForm.submit();
}
function __fncBackPrdlist(CatId,PrdCatId){
	$('hidCatId').value 		= CatId;
	$('hidPrdCatId').value 		=PrdCatId;
	$('hidPrdId').value 		='';
	if(CatId!=''){
		thisForm.txtWhat2Do.value='PRODUCTLIST';
	}else{
		thisForm.txtWhat2Do.value='';
	}
	thisForm.submit();
}
function __fncBacktoShop(){
	thisForm.txtWhat2Do.value='';
	$('hidCatId').value 		= '';
	$('hidPrdCatId').value 		='';
	$('hidPrdId').value 		='';
	thisForm.submit();
}