function reset_popular()
{
	if(confirm('Are you sure you want to reset all the products ?'))
	{
		document.getElementById('act').value="reset_popular";
		document.frm.submit();
	}
}
function show_reord(id)
{
	if(document.getElementById(id).style.display=='none')
		document.getElementById(id).style.display="";
	else
		document.getElementById(id).style.display="none";
}
function collapse_cat(cat_id)
{
var path=document.getElementById('server_path').value;
str="document.getElementById('subcat_"+cat_id+"').style.display"
if(eval(str)=="none")
{str="document.getElementById('subcat_"+cat_id+"').style.display=''"
eval(str)
str="document.cat_icon_"+cat_id+".src='"+path+"images/down_icon.png'"
eval(str)}
else
{str="document.getElementById('subcat_"+cat_id+"').style.display='none'"
eval(str)
str="document.cat_icon_"+cat_id+".src='"+path+"images/right_icon.png'"
eval(str)}}
function collapse_shops(ct_id)
{str="document.getElementById('subcate_"+ct_id+"').style.display"
if(eval(str)=="none")
{str="document.getElementById('subcate_"+ct_id+"').style.display=''"
eval(str)
str="document.cat_icons_"+ct_id+".src='images/down_icon.png'"
eval(str)}
else
{str="document.getElementById('subcate_"+ct_id+"').style.display='none'"
eval(str)
str="document.cat_icons_"+ct_id+".src='images/right_icon.png'"
eval(str)}}
function collapse_shops_retailer(ct_id)
{str="document.getElementById('subcate_ret_"+ct_id+"').style.display"
if(eval(str)=="none")
{str="document.getElementById('subcate_ret_"+ct_id+"').style.display=''"
eval(str)
str="document.cat_iconsr_"+ct_id+".src='images/downr_icon.png'"
eval(str)}
else
{str="document.getElementById('subcate_ret_"+ct_id+"').style.display='none'"
eval(str)
str="document.cat_iconsr_"+ct_id+".src='images/rightr_icon.png'"
eval(str)}}
function collapse_shops_club(ct_id)
{str="document.getElementById('subcate_club_"+ct_id+"').style.display"
if(eval(str)=="none")
{str="document.getElementById('subcate_club_"+ct_id+"').style.display=''"
eval(str)
str="document.cat_icons_"+ct_id+".src='images/down_icon.png'"
eval(str)}
else 
{str="document.getElementById('subcate_club_"+ct_id+"').style.display='none'"
eval(str)
str="document.cat_icons_"+ct_id+".src='images/right_icon.png'"
eval(str)}}
function remove_refine_search(field_name,value)
{
	if(field_name=="cat_id"||field_name=="br_id"||field_name=="sp_id")
	{
		var new_ary;new_ary="";str="ary = this.document.frm."+field_name+".value.split(\",\")"
		eval(str)
		for(i=0;i<ary.length;i++)
		{
			if(ary[i]!=value)
			{
				new_ary+=ary[i]+",";
			}
		}
		str="this.document.frm."+field_name+".value = new_ary"
		eval(str)
	}
	else
	{
		str="this.document.frm."+field_name+".value=\"\"";eval(str);
	}
	this.document.frm.submit();
}
function refine_search(field_name,value,multiple)
{
	var all_fields = new Array("br_id","sp_id","cat_id","price");
	if(multiple==1)
	{
		var new_ary,found;found=0;new_ary="";str="ary = this.document.frm."+field_name+".value.split(\",\")"
		eval(str)
		for(i=0;i<ary.length;i++)
		{
			if(ary[i]==value)
			{
				found=1;
			}
		}
		if(found==0)
			str="document.frm."+field_name+".value+=',"+value+"'";
	}
	else
		str="document.frm."+field_name+".value='"+value+"'";
	eval(str)
	
	for(i=0;i<all_fields.length;i++)
	{
		if(all_fields[i]!=field_name)
		{
			str="document.frm."+all_fields[i]+".value=''";
			eval(str);
		}
	}
	
	document.frm.submit();
}
function remove_shop_search()
{
	var path = document.getElementById('server_path').value;
/*	document.frm.action=path+"index.php";
	document.frm.submit();*/
	location.href=path+"index.php";
}
function help(content)
{content="<br /><div style=\"width:90%; margin-left:10px\"><div style=\"border-bottom:1px solid #999999; text-align:left\" height=\"30\"><b>Help</b></div></div>"+"<br/><div style=\"padding:10px\">"+content+""+"</div>"+"<div style=\"padding-top:80px\"><input type=\"button\" name=\"close\" value=\" Close \" onclick=\"javascript:closeme()\"></div>";win=cn_window_open("Help Content","",content,450,250,true,true,true)}
function closeme()
{window.close();}
function view_more_cat(olListId)
{
	var k=1;var d=document;var ary=d.getElementById(olListId).getElementsByTagName("li");var i=0;ary[10].style.display="none";
	for(i=0;i<ary.length;i++)
	{
		if(ary[i].id=="sho_hide")
		{
			ary[i].style.display="";
			if(k==11)
				ary[i].style.display="none";k++;
		}
	}
}
function view_less_cat(olListId)
{
	var k=1;var d=document;var ary=d.getElementById(olListId).getElementsByTagName("li");var i=0;ary[10].style.display="";
	for(i=0;i<ary.length;i++)
	{
		if(ary[i].id=="sho_hide")
		{
			if(k>11)
				ary[i].style.display="none";
			else
				ary[i].style.display="";k++;
		}
	}
}
function view_more(olListId)
{var d=document;var ary=d.getElementById(olListId).getElementsByTagName("li");var i=0;ary[10].style.display="none";for(i=11;i<ary.length;i++)
ary[i].style.display="";}
function view_less(olListId)
{var d=document;var ary=d.getElementById(olListId).getElementsByTagName("li");var i=0;ary[10].style.display="";for(i=11;i<ary.length;i++)
ary[i].style.display="none";}
function change_currency(a)
{var url,len;url=location.href;len=url.indexOf('currency');if(len>0)
url=url.substr(0,len-1)
if(url.indexOf('?')=='-1')
url=url+'?currency='+a;else
url=url+'&currency='+a;window.location.href=url;}
function nb(a)
{this.document.frm.st_pos.value=a;this.document.frm.submit();}
function owner_del(a)
{if(confirm("Are you sure you want to delete selected Product?"))
{this.document.frm.prod_id.value=a;this.document.frm.act.value="delete_product";this.document.frm.submit();}}
function set_order(f,o)
{this.document.frm.orderby.value=f;this.document.frm.order.value=o;this.document.frm.submit();}
function search_product()
{this.document.frm.act.value="view_products";this.document.frm.submit();}
function set_order1()
{this.document.frm.orderby.value=this.document.frm.short_by.value;if(this.document.frm.order.value=="ASC")
this.document.frm.order.value="DESC";else
this.document.frm.order.value="ASC";this.document.frm.submit();}
function change_type()
{document.frm.view_as_list.value="yes";document.frm.nb_vlue.value=5;document.frm.st_pos.value=0;document.frm.submit();}
function show_records(nbval)
{this.document.frm.nb_vlue.value=nbval;this.document.frm.submit();}
function add_cart(prod_id)
{this.document.frm.prod_id.value=prod_id;this.document.frm.act.value="add_to_cart";this.document.frm.submit();}
function chk()
{var f;f=this.document.frm;var fields=new Array("l_fname","l_lname","l_shop_name","l_email","l_password","l_address1","l_city");var i=0;var flag2=0;for(i=0;i<fields.length;i++)
{var tag=fields[i]+'_tag'
var tag_text=fields[i]
if(document.getElementById(fields[i]).value=="")
{document.getElementById(tag).style.color='#FF0000'
document.getElementById(tag_text).style.background='#FFCCCC'
flag2=1;}
else
{document.getElementById(tag).style.color='#000000'
document.getElementById(tag_text).style.background='#FFFFFF'}}
if(f.country.value==-1)
{flag2=1;document.getElementById('country_tag').style.color='#FF0000'
document.getElementById('country').style.background='#FFCCCC'}
else
{document.getElementById('country_tag').style.color='#000000'
document.getElementById('country').style.background='#FFFFFF'}
if(document.getElementById('reg_tr').style.display=="")
{if(f.region.value==-1)
{flag2=1;document.getElementById('region_tag').style.color='#FF0000'
document.getElementById('region').style.background='#FFCCCC'}
else
{document.getElementById('region_tag').style.color='#000000'
document.getElementById('region').style.background='#FFFFFF'}}
if(f.l_cr_id.value==-1)
{flag2=1;document.getElementById('corrency_tag').style.color='#FF0000'
document.getElementById('corrency').style.background='#FFCCCC'}
else
{document.getElementById('corrency_tag').style.color='#000000'
document.getElementById('corrency').style.background='#FFFFFF'}
if(document.getElementById('bank_account1').checked==false && document.getElementById('bank_account2').checked==false)
{
	document.getElementById('bank_account1_tag').style.color='#FF0000'
	document.getElementById('bank_account1').style.background='#FFCCCC'
	flag2=1;
}
else
{
	document.getElementById('bank_account1_tag').style.color=''
	document.getElementById('bank_account1').style.background='#FFFFFF'
}
if(document.getElementById('bank_account1').checked==true && document.getElementById('l_paypal_email').value=="")
{
		document.getElementById('l_paypal_email_tag').style.color='#FF0000'
		document.getElementById('l_paypal_email').style.background='#FFCCCC'
		flag2=1;
}
else
{
		document.getElementById('l_paypal_email_tag').style.color=''
		document.getElementById('l_paypal_email').style.background='#FFFFFF'
}
if(document.getElementById('bank_account2').checked==true && (document.getElementById('l_bank_name').value=="" || document.getElementById('l_account_name').value=="" || document.getElementById('l_bank_sort_code').value=="" || document.getElementById('l_bank_acc_no').value=="" || document.getElementById('l_contact_email').value=="" || document.getElementById('l_contact_phone').value==""))
{
		document.getElementById('l_bank_name_tag').style.color='#FF0000'
		document.getElementById('l_bank_name').style.background='#FFCCCC'
		document.getElementById('l_account_name_tag').style.color='#FF0000'
		document.getElementById('l_account_name').style.background='#FFCCCC'
		document.getElementById('l_bank_sort_code_tag').style.color='#FF0000'
		document.getElementById('l_bank_sort_code').style.background='#FFCCCC'
		document.getElementById('l_bank_acc_no_tag').style.color='#FF0000'
		document.getElementById('l_bank_acc_no').style.background='#FFCCCC'
		document.getElementById('l_contact_email_tag').style.color='#FF0000'
		document.getElementById('l_contact_email').style.background='#FFCCCC'
		document.getElementById('l_contact_phone_tag').style.color='#FF0000'
		document.getElementById('l_contact_phone').style.background='#FFCCCC'
		flag2=1;
}
else
{
		document.getElementById('l_bank_name_tag').style.color=''
		document.getElementById('l_bank_name').style.background='#FFFFFF'
		document.getElementById('l_account_name_tag').style.color=''
		document.getElementById('l_account_name').style.background='#FFFFFF'
		document.getElementById('l_bank_sort_code_tag').style.color=''
		document.getElementById('l_bank_sort_code').style.background='#FFFFFF'
		document.getElementById('l_bank_acc_no_tag').style.color=''
		document.getElementById('l_bank_acc_no').style.background='#FFFFFF'
		document.getElementById('l_contact_email_tag').style.color=''
		document.getElementById('l_contact_email').style.background='#FFFFFF'
		document.getElementById('l_contact_phone_tag').style.color=''
		document.getElementById('l_contact_phone').style.background='#FFFFFF'
}
if(flag2==1)
{msg='Some fields require your attention. ';document.getElementById('msg_id').innerHTML=msg
return false;}
if(!chk_email(f.l_email.value))
{msg='Please enter your correct email address using @.';document.getElementById('msg_id').innerHTML=msg
return false;}
f.submit();}
function change_country(ct_id)
{
	document.getElementById('dhl_rates').style.display="none";
	if(ct_id==5)
		document.getElementById('dhl_rates').style.display="";
	x_region_view(ct_id,op_region);
}
function op_region(js)
{document.getElementById('region').innerHTML=js;document.getElementById('reg_tr').style.display="";}
function chk_email(v)
{f1=0;f2=0;for(j=0;j<v.length;j++)
{if(v.charAt(j)=='@')
{f1=j+1;}
if(v.charAt(j)=='.')
{f2=j+1;}}
if(f1==0||f2==0)
{return false;}
else
{return true;}}
function payment_getway()
{
	document.getElementById('bank_acc1').style.display="none"
	document.getElementById('bank_acc2').style.display="none"
	if(document.getElementById('bank_account1').checked==true)
		document.getElementById('bank_acc2').style.display="";
	else
		document.getElementById('bank_acc1').style.display="";
}
function show_pickup_detail(is_show)
{document.getElementById('pickup_details').style.display=is_show;}
//--
//Temporary product image upload
function open_window(js)
{
	cn_window_open("product_id","",js,400,180,true,true,true,2);
}
function open_upload(prod_id)
{
	var f=document.frm 
	f.act.value="upload_temp_prod_file";
	f.prod_id.value=prod_id;
	f.target="submitFrame";
	f.submit();
}
// upload function 
function check_upload()
{
    var a=document.getElementById("file_name").value;
  
    if( a =="" && ''=='' )
		alert("Please select a image file.");		
	else if(a.search(".JPEG")!= -1 || a.search(".JPG") != -1 || a.search(".jpeg") != -1 || a.search(".jpg") != -1 || a.search(".png") != -1 || a.search(".PNG") != -1 || a.search(".gif") != -1 || a.search(".GIF") != -1   ) 
	{
		document.frm_upload.submit();
	}
	else
		alert("Please upload .jpg,.jpeg,gif or .png file only !");
}
function refresh_upload(js)
{
	
	var d=document;
	d.getElementById('msg').innerHTML="File uploaded successfully.";
	//win.hide();
	//d.getElementById("upload_data").innerHTML=js[0];
	//d.getElementById("up_ids").value=js[1];
}
function del_up(up_id)
{
	var f=document.frm 
	f.act.value="del_prod_upload";
	f.up_id.value=up_id;
	f.target="submitFrame";
	f.submit();
}
//--------------------------------------------------------
function upload_file(prod_id)
{
	var f=document.frm 
	f.act.value="upload_file_do";
	f.prod_id.value=prod_id;
	f.target="submitFrame";
	f.submit();
	
}
function select_all()
{
	 var che,i;
	 che=document.getElementsByTagName("input");
	
	if(document.getElementById("select_all").checked==false)
		document.getElementById("select_all").checked=true;
	else
		document.getElementById("select_all").checked=false;
		
	
	if(document.getElementById("select_all").checked==true)
	{
	
		 for(i=0; i<che.length ; i++)
		 {
			if(che[i].type=="checkbox" && che[i].name=="prod_id[]" )
			  che[i].checked=true;
		 }
	}
   else
    {
	
		for(i=0; i<che.length ; i++)
		 {
			if(che[i].type=="checkbox" && che[i].name=="prod_id[]" )
			  che[i].checked=false;
		 }
	}   	
		 
}

function  get_ids( f_name ) 
{
	var d= new Array(); 
	var tag_type="checkbox";
	//var f_name="exp_id[]";
	var flag;
	var i;
	var id="";
	
	flag=0;
	i=0;
	
	d=this.document.getElementsByTagName("input");
	while( i<d.length )
	{
		if(f_name==d[i].name && d[i].checked==true && d[i].type==tag_type )
		{
			id=(id+d[i].value+",");
		
		}	
	i=i+1;
	}
	id=id.substr(0,id.length-1);
	
	//alert(id);
	return id;	 
}

function show_price_limit()
{
	document.getElementById('free_shipping').style.display="";
	if(document.getElementById('price_limit').checked==false)
		document.getElementById('free_shipping').style.display="none";
		
}
