var slide_speed=30;var XmlHttp; var current_mrchnd_id; var current_prod_id; var current_prod_size_id; var current_prod_clr_id; var current_prod_cost; var current_discount=0; var realpricecharged; var originalprice = 0; var selected_prod_id; var quantity; var is_click=0; var is_size_change=0; var dummy=new Array(); var sizearr=new Array(); var bkprev = 0; var frontprev = 0; var clickbkpath; var clickftpath; var is_change_col = 0; var rotateprodid; var backclick = 0; function ProgressAnimation(dowat, message) { if (dowat == 1) { var message = message || 'Loading...Please wait.....'; $BF('prmsg', message);}
if (dowat == 1){ $GE('progressanimation').style.visibility = 'visible';} else { $GE('progressanimation').style.visibility = 'hidden';}
}
function dispTick(cid){ $GE('f_'+cid).style.visibility='visible';}
function hideTick(did){ $GE('f_'+did).style.visibility='hidden';}
function rotateimg(prid,bkimgpath,bkpath) { 
	rotateprodid = prid; 
	/*$GE('im_'+prid).style.backgroundImage = 'url("' +bkimgpath+ '")';*/ 
	if($GE('bkpev_'+prid).style.display == 'block') { 
		bkprev = 1; frontprev =0; 
		$GE('bkpev_'+prid).style.display = 'none'; 
		$GE('fntpev_'+prid).style.display = 'block';
		$GE('im_'+prid).style.display='none';
		$GE('imbk_'+prid).style.display='block';
		$GE('imbk_'+prid).style.width=$GE('imbkwdt').value;
		$GE('imbk_'+prid).style.height=$GE('imbkhgt').value;		
	} else { 
		frontprev =1; bkprev = 0; 
		$GE('bkpev_'+prid).style.display = 'block'; 
		$GE('fntpev_'+prid).style.display = 'none';
		$GE('im_'+prid).style.display='block';
		$GE('imbk_'+prid).style.display='none';		
	}
if(rotateprodid == selected_prod_id) { if(frontprev == 1) { $GE('p_'+prid).style.backgroundImage = 'url("' +clickftpath+ '")';} else if(bkprev == 1){ $GE('p_'+prid).style.backgroundImage = 'url("' +clickbkpath+ '")';}
} else { $GE('p_'+prid).style.backgroundImage = 'url("' +bkpath+ '")';}
} 
function swapimg(thumbimgpath,orgimgpath,thumbimgpath1,orgimgpath1) { if(backclick == 1) { $GE('dsgthumb').style.backgroundImage = 'url("' +thumbimgpath1+ '")'; $GE('orgimg').style.backgroundImage = 'url("' +orgimgpath1+ '")'; if($GE('fthumb').style.display == 'block') { $GE('fthumb').style.display = 'none'; $GE('bthumb').style.display = 'block'; } else { $GE('fthumb').style.display = 'block'; $GE('bthumb').style.display = 'none';}	backclick = 0; } else {	$GE('dsgthumb').style.backgroundImage = 'url("' +thumbimgpath+ '")'; $GE('orgimg').style.backgroundImage = 'url("' +orgimgpath+ '")'; if($GE('fthumb').style.display == 'block') { $GE('fthumb').style.display = 'none'; $GE('bthumb').style.display = 'block';	} else { $GE('fthumb').style.display = 'block'; $GE('bthumb').style.display = 'none';} backclick = 1; }
} 
function selectcol(id,divid,path,colarr,bkkpath){ $BF(divid+'_fin_ps','<img src = "/image/loading_small.gif" border="0" >'); $GESD(divid+'_buynowbutton', 'none'); var temp = colarr.split(","); clickbkpath = bkkpath; clickftpath = path; is_change_col = 1; for (var i=0; i < temp.length; i++) { if('t_'+temp[i] == 't_'+id ) { $GE('t_'+temp[i]).style.visibility='visible'; is_click = 1; selected_prod_id = divid; dummy[divid] = temp[i]; var curr_prod_size_id = $GE(selected_prod_id+'_psize').value; var url = '/dz_lab_ajax_controller'; var prm = 'provider=calculate_price&design_id='+design_id+'&prod_col_id='+temp[i]+'&has_bk_img='+back_image_exist+'&prod_size_id='+curr_prod_size_id+'&is_public='+is_public; XmlHttp = $GX(); XmlHttp.onreadystatechange= function getPrice() { if (XmlHttp.readyState == 4 || XmlHttp.readyState == "complete") { var psresult = eval('(' + XmlHttp.responseText+ ')')
if(psresult.success == 0) { alert('Ooops... there is some problem calculating price for your selection. Please try again and if problem persists, then please contact us at customercare@pringoo.com');} else { realpricecharged = psresult.real; originalprice = psresult.total; $BF(selected_prod_id+'_fin_ps',psresult.mssg);} $GESD(divid+'_buynowbutton', 'block');
}
}
XmlHttp.open("POST",url,true); $Header(XmlHttp,prm);} else { $GE('t_'+temp[i]).style.visibility='hidden';}
}
if(rotateprodid == divid) { if(frontprev == 1) { $GE('p_'+divid).style.backgroundImage = 'url("' +clickftpath+ '")';} else if(bkprev == 1){ $GE('p_'+divid).style.backgroundImage = 'url("' +clickbkpath+ '")';}
} else { $GE('p_'+divid).style.backgroundImage = 'url("' +clickftpath+ '")';}
} 
function getfinalprice(psize_id,cu_prod_id,cu_prod_col_id) { $BF(cu_prod_id+'_fin_ps','<img src = "/image/loading_small.gif" border="0" >'); $GESD(cu_prod_id+'_buynowbutton', 'none'); var dd = $GE(psize_id).value; var fi_pcl_id; sizearr[cu_prod_id] = 1; if(selected_prod_id != undefined && cu_prod_id == selected_prod_id) { if(is_click == 1) { fi_pcl_id = dummy[cu_prod_id];}
} else if(dummy[cu_prod_id] && dummy[cu_prod_id] != undefined && dummy[cu_prod_id] != '') { fi_pcl_id = dummy[cu_prod_id];} else { fi_pcl_id = cu_prod_col_id;}
var url = '/dz_lab_ajax_controller'; var prm = 'provider=calculate_price&design_id='+design_id+'&prod_col_id='+fi_pcl_id+'&has_bk_img='+back_image_exist+'&prod_size_id='+dd+'&is_public='+is_public; XmlHttp = $GX(); XmlHttp.onreadystatechange= function getpPrice() { if (XmlHttp.readyState == 4 || XmlHttp.readyState == "complete") { var sresult = eval('(' + XmlHttp.responseText+ ')')
if(sresult.success == 0) { alert('Ooops... there is some problem calculating price for your selection. Please try again and if problem persists, then please contact us at customercare@pringoo.com');} else { realpricecharged = sresult.real; originalprice = sresult.total; $BF(cu_prod_id+'_fin_ps',sresult.mssg);} $GESD(cu_prod_id+'_buynowbutton', 'block');
}
}
XmlHttp.open("POST",url,true); $Header(XmlHttp,prm);}
function assignValues(av_pid,av_psid,av_pclid,av_mrchnd_id,av_prod_cost,av_cd,av_quant) { current_mrchnd_id = av_mrchnd_id; current_prod_id = av_pid; current_prod_size_id = av_psid; current_prod_clr_id = av_pclid; current_prod_cost = av_prod_cost; current_discount = av_cd; quantity = av_quant;}
function getpriceString(ppprice, imagcost, hastwosides, discount) { var merchandiseid = current_mrchnd_id; var totalprice; if (hastwosides == 1) { var hasitem_both_side = 0; if (back_image_exist == 1) { hasitem_both_side = 1;}
if (discount > 0) { if (hasitem_both_side == 1) { ppprice = ppprice + imagcost; totalprice = ppprice + ppprice*(mprofits[merchandiseid]/100); discprice = Math.ceil(totalprice - (totalprice*(discount/100)));} else { totalprice = ppprice + ppprice*(mprofits[merchandiseid]/100); discprice = Math.ceil(totalprice - (totalprice*(discount/100)));}
realpricecharged = Math.ceil(discprice); originalprice = totalprice; return 'Price: Rs. <del style="color:#FF0000;">'+Math.ceil(totalprice)+'</del> '+realpricecharged;} else { if (hasitem_both_side == 1) { ppprice = ppprice + imagcost; totalprice = ppprice + ppprice*(mprofits[merchandiseid]/100);} else { totalprice = ppprice + ppprice*(mprofits[merchandiseid]/100);}
realpricecharged = Math.ceil(totalprice); originalprice = realpricecharged; return 'Price: Rs. '+realpricecharged;}
} else { totalprice = ppprice + ppprice*(mprofits[merchandiseid]/100); if (discount > 0) { discprice = Math.ceil(totalprice - (totalprice*(discount/100))); realpricecharged = Math.ceil(discprice); originalprice = totalprice; return 'Price: Rs. <del style="color:#FF0000;">'+Math.ceil(totalprice)+'</del> '+realpricecharged;} else { realpricecharged = Math.ceil(totalprice); originalprice = realpricecharged; return 'Price: Rs. '+realpricecharged;}
}
}
function addThisProduct(merchandiseid,prd_id,pcl_id,psid,pprice,discou,quant,twosd,img_cst,ttprice,rrprice) { 
	var final_pcl_id; 	
	if(quant == 'quantity'){
		alert('Please select quantity');
		return;
	}
	if($GE(prd_id+'_ppsize').value == 'size'){
		alert('Please select Size');
		return;
	}
	if(selected_prod_id != undefined && prd_id == selected_prod_id) { 
		if(is_click == 1) { 
			final_pcl_id = dummy[prd_id];
		}
    } else if(dummy[prd_id] && dummy[prd_id] != undefined && dummy[prd_id] != '') { 
    	final_pcl_id = dummy[prd_id];
    } else { 
    	final_pcl_id = pcl_id;
    }
   assignValues(prd_id,psid,final_pcl_id,merchandiseid,pprice,discou,quant); 
   var cflag =0; 
   if(dummy[prd_id] && dummy[prd_id] != undefined && dummy[prd_id] != '') { 
     	 cflag =1;
     } else if(sizearr[prd_id] && sizearr[prd_id] != undefined && sizearr[prd_id] != '' && sizearr[prd_id] == 1) { 
     	cflag =1;
     }
   if(cflag == 0) { 
     	originalprice = ttprice; 
    	realpricecharged = rrprice;
     }
   UserLoggedInforSaving();
}
function UserLoggedInforSaving() { $GE(current_prod_id+'_buynowbutton').src = '/image/loading_small.gif'; if (quantity <= 0) { alert('Please select quantity for this product order.'); $GE(current_prod_id+'_buynowbutton').src = '/image/designlab/btn-buyNow2.gif'; return;}
var url = '/dz_lab_ajax_controller'; var prm = 'provider=auth'; XmlHttp = $GX(); XmlHttp.onreadystatechange= function dummy() { if (XmlHttp.readyState == 4 || XmlHttp.readyState == "complete") { var authresult = eval('(' + XmlHttp.responseText+ ')')
if(authresult.success == 0) { alert('You need to sign in to your account to place the order.\n\n-------\n\n If you are not a member yet then please sign up.'); $GE(current_prod_id+'_buynowbutton').src = '/image/designlab/btn-buyNow2.gif'; openDiv(1, 0, 'Please click ADD TO CART button AGAIN to confirm your selection.'); } else { saveincart();}
}
}
XmlHttp.open("POST",url,true); $Header(XmlHttp,prm);}
function saveincart() { 
	var qnt = quantity;
//	alert(qnt);  
	if (qnt <= 0) { 
		alert('Please select quantity.'); 
		return;
	}
   var url = '/dz_lab_ajax_controller?provider=saveincart&merid='+current_mrchnd_id+'&pclid='+current_prod_clr_id+'&psid='+current_prod_size_id+'&did='+design_id+'&pid='+current_prod_id+'&q='+qnt+'&pr='+originalprice+'&prcharge='+realpricecharged+'&dis='+current_discount; 
   var XmlHttpd = $GX(); XmlHttpd.onreadystatechange= function dummy() { 
   	if (XmlHttpd.readyState == 4 || XmlHttpd.readyState == "complete") { 
   		var sresult = eval('(' + XmlHttpd.responseText+ ')');
   		 if (sresult.success == 1) { 
   		 	openShopForm();
   		 } else { 
   		 	alert(sresult.msg);
   		 }
}
}
XmlHttpd.open("GET",url,true); $Header(XmlHttpd);}
function addwishlist(wpclid) { var oldhtml = $GE('add2wl').innerHTML; $GE('add2wl').innerHTML = "<img style='margin-left:100px;' src='/image/loading_small.gif' /><br />"; var url = '/ajax_controller'; var prm = 'provider=addwishlist&prod_col_id='+wpclid+'&design_id='+design_id; var XmlHttp = $GX(); XmlHttp.onreadystatechange=function Show(){ if (XmlHttp.readyState == 4 || XmlHttp.readyState == "complete") { if(XmlHttp.responseText == 1) { alert('You need to sign in to your account to save this designed product in your wishlist.'); openDiv(1,0,"Now you have signed in successfully. \n\nPlease click 'Add to Wish List' AGAIN to confirm.");} else { alert(XmlHttp.responseText);} $GE('add2wl').innerHTML = oldhtml;} 
} 
XmlHttp.open("POST",url,true); $Header(XmlHttp,prm);} 
function openAbuseForm() { $GESD('rabuseform', 'block'); $setPopup('rabuseform','abuseHeader','abuseMenuHeader','form_abuse',300,300,1,'abuseform');}
function openShopForm() { $GESD('sform', 'block'); $setPopup('sform','sHeader','sMenuHeader','form_shop',380,125,1,'shopform');}
function close_popup(div){ $GESD(div,'none');}
function close_popupdiv(div){ $GESD(div,'none'); $GE(current_prod_id+'_buynowbutton').src = '/image/designlab/btn-buyNow2.gif';}
function aformsubmit(designid,design) { $GE('coster').src = '/image/loading_small.gif'; var yemail = $GE('youremailid').value; var mssg = $GE('abuse_msg').value; if(mssg=='' || yemail=='') { alert("All fields are mandatory."); $GE('coster').src = '/image/btn-postit.gif';} else { if(mssg.length > 500) { alert("Message should not be greater than 500 characters long."); $GE('coster').src = '/image/btn-postit.gif';} else { var prm = 'provider=reportabuse&design_id='+designid+'&design='+design+'&youremailid='+yemail+'&abuse_msg='+mssg; var url = '/ajax_controller'; XmlHttp = $GX(); XmlHttp.onreadystatechange=function showResult1() { if (XmlHttp.readyState == 4 || XmlHttp.readyState == "complete") { var resultofrequest1 = eval('(' + XmlHttp.responseText + ')')
if(resultofrequest1.success == 1) { close_popup('abuseform'); alert('Abuse report has been sent successfully.');} else { alert(resultofrequest1.message);}
$GE('coster').src = '/image/btn-postit.gif';}
}
XmlHttp.open("POST",url,true); $Header(XmlHttp,prm);}
}
}
function getohrprod(cdid, cmid,fmname) {
	if(fmname != 0 && fmname.length > 0) {
		alert('You may see a light blue background in design on '+fmname+'. This background will be removed while printing it.' );
	}
	parent.document.getElementById(cmid+'_othercont').innerHTML = '<img src="/image/loading_small.gif" border="0" align="absmiddle" style="margin-top:88px;"/>'; 
	var prm = 'provider=getcustomdsg&did='+cdid+'&mid='+cmid; 
	var url = '/custom_ajax_controller'; XmlHttp = $GX(); 
	var tid = cmid+'_ajxres'; 
	XmlHttp.onreadystatechange=function disResult() { 
		if (XmlHttp.readyState == 4 || XmlHttp.readyState == "complete") { 
			var cresult = XmlHttp.responseText ; 
			
			if(parent.document.getElementById(cmid+'_ajxres').innerHTML = cresult){ 			
				var m_h=document.getElementById('m_height'+cmid).value; 
				var m_div=document.getElementById('container_ajx').style.height;
//				alert(m_h);
				m_div=parseInt(m_div);
				m_h=parseInt(m_h);							
				m_h=m_h+m_div;
				slide_d(m_h,m_div);				
			}
			parent.document.getElementById(cmid+'_othercont').innerHTML = '<img src="" border="0" />'; 
			parent.document.getElementById(cmid+'_othercont').style.display = 'none';
		}
    }
  XmlHttp.open("POST",url,true); 
  $Header(XmlHttp,prm);
}
//var sel_flag = 0;
//function makeflag() { 	
//	sel_flag = 0; 
//}
//function makedf() {	
//	sel_flag = 1;	
//}
function dispBotBox1(bid) { $GE(bid+'_csqbox').style.display='block'; 
}
function dispBotBox2(bid) { /*$GESD(bid+'_psizediv','none');*/ $GE(bid+'_csqbox').style.display='none'; 
}
// function for checking quantity is enterd or not 
function check_isset(iid){
	var tt=$GE(iid).value;	
    var val=parseInt(tt); 
    var val2=String(val).length;    
	if(tt != " "){		
		if(isNaN(val)){
		   $GE(iid).value='quantity';
		   alert('Enter valid quantity');
		}else{
		  if(val2 != tt.length){
		  	   $GE(iid).value='quantity';
		  	   alert('Enter valid quantity');
		  	}else{
		       if(val > 25){
		          $GE(iid).value='quantity'; 
		  	      alert('For quantity more than 25 items, please visit www.pringoo.com/bulk to get bulk discount as it will not be processed through regular shopping.');
		        }else{  	
	              return;
		  	    }
		   }	 
		}		
	}else{
		$GE(iid).value='quantity';
	}
}

function slide_d(m_h,m_d){
	var d_h=m_h;
	var max_h=m_d; 
	max_h=parseInt(max_h);
//	alert(max_h+'jhg'+d_h);
	if(max_h != d_h){
		max_h=max_h+slide_speed;
		document.getElementById('container_ajx').style.height=max_h+'px';
		setTimeout('slide_d('+d_h+','+max_h+')',1);
	}else{
	   document.getElementById('container_ajx').style.height=max_h+'px';
	}
}
function viewreviews(url) {    
	openwindow1=window.open(url,'Design_Details','height=500, width=700, resizable=yes, scrollbars=yes, toolbar=no, status=yes');
	if(window.focus) {
		openwindow1.focus();
	}
}
function closediv(cdid) {
	fid = cdid+'_psizediv';
	$GESD(fid,'none');
}
function show_link_sharer(diid) {
	//var cor = window.ifram.current_orientation;
	var pcid = current_prod_clr_id;
	//url = "http://pringoo.com/web2/sharelink/d-"+diid+'/o-'+cor+'/pc-'+pcid;
	url = "http://pringoo.com/web2/sharelink/d-"+diid;
	openwindow22=window.open(url,'Sharethisdesign','height=700, width=500, resizable=yes, scrollbars=yes, toolbar=no, status=yes');
	if(window.focus) {
		openwindow22.focus(); 
	}
}