// JavaScript Document

function set_tab_class(div_nm,clasnm){
	document.getElementById(div_nm).className = clasnm;
}

function all_subtab_hide(){
	set_tab_class("pd_op1", "productpadding1 com_none");
	set_tab_class("pd_op2", "productpadding1 com_none");
	
	set_tab_class("tb1", "linknor");
	set_tab_class("tb2", "linknor");
}

function display_subtab(dvid){
	all_subtab_hide();
	set_tab_class("tb"+dvid, "linkactv");
	set_tab_class("pd_op"+dvid, "productpadding1 com_block");	
}

function searchform(){
	if(!validate_text(document.skey.pkeyword,1,"Please enter the search Keyword")){
	  return false;
    } 
	
	return true;
}

function go_to_category_page(selectedid, folpth, sale_filter){	
	if (selectedid != ""){ location.href = folpth + 'go_to_category_page.php?cid=' + selectedid + "&sale_filter=" + sale_filter; }
}

function go_to_gallerycategory_page(selectedid, folpth){	
	if (selectedid != ""){ location.href = folpth + 'go_to_gallerycategory_page.php?cid=' + selectedid; }
}

function con_check(){  
			
		/*if(!validate_text(document.con_ff.fname,1,"Please enter First Name")){
			 return false;
		}
		
		if(!validate_text(document.con_ff.lname,1,"Please enter Last Name")){
			 return false;
		}*/
		
		if(!validate_text(document.con_ff.name,1,"Please enter Name")){
			 return false;
		}
				 
		if(!validate_email(document.con_ff.email,1,"Please enter Email Address")){
			 return false;
		} 
		
		/*if(allTrim(document.con_ff.email.value) != allTrim(document.con_ff.cemail.value)){
          alert("For verification purposes, please enter your Email Address exactly as you entered it previously");         
          //document.ff.email.value = "";
          document.con_ff.cemail.focus();
          return false;
        }*/
		 
		if(!validate_text(document.con_ff.mess,1,"Please enter Comments/Request")){
			 return false;
		}
		 
		if(!validate_text(document.con_ff.captcha,1,"Please enter Confirmation Code")){
			return false;
		}  
  
     return true;  
   }
   
function l_checkk(){
 
 if(!validate_email(document.m_lgn.t1,1,"Please enter your Email Address")){
	 return false;
 }
 
 if(!validate_text(document.m_lgn.t2,1,"Please enter your Password")){
	 return false;
 } 

 return true;
}

function p_checkk(){
 
 if(!validate_email(document.pass_ff.un_em,1,"Please enter your Email Address")){
	 return false;
 }
 return true;
}

function newsletter_check_small(){ 
 if(!validate_text(document.news_ff_s.name,1,"Please enter your Name")){
	 return false;
 }
 
 if(!validate_email(document.news_ff_s.email,1,"Please enter your Email Address")){
	 return false;
 }
 return true;
}

function add_to_cart_ck(){
	if(!validate_pnumeric(document.ff.mquan,1,"Please enter Valid Quantity")){
	 return false;
    }
	
	return true;
}

function expand(s, aclink, acclass){
  var td = s;
  var d = td.getElementsByTagName("div").item(0);
  if (d){
  td.className = "menuHover";
  d.className = "menuHover";
  }
  //alert(aclink);
  document.getElementById(aclink).className = acclass;
}

function collapse(s, aclink, acclass){
  var td = s;
  var d = td.getElementsByTagName("div").item(0);
  if (d){
  td.className = "menuNormal";
  d.className = "menuNormal";
  }
  //var current_cls = document.getElementById(aclink).className;
  //if (current_cls != "toplinkac"){
  document.getElementById(aclink).className = acclass;
  //}
}

var liveReqp = "";
var print_dt = "";
var chng = "";
var chng_1 = "";

function getdata(aa,tb,fld,folpth) {			
	chng = fld;
	
	if (window.XMLHttpRequest) {
		liveReqp = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveReqp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	var sURL = folpth + "includes/get_cat.php?id="+aa+"&tbl="+tb;
	liveReqp.onreadystatechange = receivercode;
	liveReqp.open("GET", sURL);		
	liveReqp.send(null);
}

function receivercode(){
   if (liveReqp.readyState == 4) {
          
       var nummd =  document.getElementById(chng).length;	   
	   while(nummd > 1) {
		   nummd--;
		   document.getElementById(chng).options[nummd] = null;
	   }				    
	    
		var str=liveReqp.responseText;			
		var str_sr=str.split("#");
		var str_ln=str_sr.length
	
	    for (var k=0;k<str_ln-1;k++){
			 var second_sr=str_sr[k].split("/!");
			 document.getElementById(chng).options[k+1] = new Option(second_sr[0], second_sr[1]);
	    }
	}
 }
 
 function getdata_new(aa,tb,fld,fld_1,folpth) {			
	chng = fld;
	chng_1 = fld_1;
	
	if (window.XMLHttpRequest) {
		liveReqp = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveReqp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	var sURL = folpth + "includes/get_cat.php?id="+aa+"&tbl="+tb;
	liveReqp.onreadystatechange = receivercode_new;
	liveReqp.open("GET", sURL);		
	liveReqp.send(null);
}

function receivercode_new(){
   if (liveReqp.readyState == 4) {
          
       var nummd =  document.getElementById(chng).length;	   
	   while(nummd > 0) {
		   nummd--;
		   document.getElementById(chng).options[nummd] = null;
	   }				    
	    
		var str=liveReqp.responseText;			
		var str_sr=str.split("#");
		var str_ln=str_sr.length
	
	    for (var k=0;k<str_ln-1;k++){
			 var second_sr=str_sr[k].split("/!");
			 document.getElementById(chng).options[k] = new Option(second_sr[0], second_sr[1]);
	    }
		
		nummd =  document.getElementById(chng_1).length;	   
	    while(nummd > 0) {
		   nummd--;
		   document.getElementById(chng_1).options[nummd] = null;
	    }
		
	}
 }
 
var un_folpth = "";
function get_color_image(att_vl_id, product_id, folpth){
	un_folpth = folpth;
    if (window.XMLHttpRequest) {
		liveReqp = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveReqp = new ActiveXObject("Microsoft.XMLHTTP");
	}

	var sURL = folpth + "includes/get_color_image.php?att_vl_id="+att_vl_id+"&product_id="+product_id;
	liveReqp.onreadystatechange = receive_color_image;
	liveReqp.open("GET", sURL);		
	liveReqp.send(null);
}

function receive_color_image(){
	if (liveReqp.readyState == 4){
		var image_str = liveReqp.responseText;
		if (image_str != "n"){
			var image_str_ar = image_str.split("/!");
			document.getElementById("bigimage").href = un_folpth + "productimg/bigger/" + image_str_ar[1];
			document.images["ap1"].src = un_folpth + "productimg/big/" + image_str_ar[1];
			document.getElementById("pane2").innerHTML = image_str_ar[0];	
			$('#pane2').jScrollPane({showArrows:true});
		}else{
			document.getElementById("bigimage").href = un_folpth + "productimg/bigger/no.jpg";
			document.images["ap1"].src = un_folpth + "productimg/big/no.jpg";
			document.getElementById("pane2").innerHTML = "";
			$('#pane2').jScrollPane({showArrows:true});
		}
	}
}

function f_order_det(aa)
   {  
	var url = 'order-det.php?id='+aa;
	var ttl = 'Order';
	var params = 'status=yes, resizable=yes ,width=750px, height=500px, top=10px, left=10px, scrollbars=yes';
	window.open(url, ttl, params);
   }

function jump_page(p, gotopagenm, extraqry){
	location.href = gotopagenm + '?p=' + p + extraqry;
}

function pageitemgo(){
 location.href = document.pgnat.gotourl.value + "&pageitem=" + document.pgnat.pageitem.value;
} 
function pageitemgo_1(){
 location.href = document.pgnat_1.gotourl.value + "&pageitem=" + document.pgnat_1.pageitem.value;
}

function make_round(ab){
	  val=""+Math.round(100*ab); 
	  while (val.length <= 2) {
	    val="0"+val 
	  }
	var dec_point=val.length-2;  
	var first_part=val.substring(0,dec_point);
	var second_part=val.substring(dec_point,val.length); 
	var result=first_part+"."+second_part;
	return result;
}
