// JavaScript Document

//Submit Search Form

function DoSearch() 
	{
	document.location.href = "http://www.proformancelogo.com/search-results.php?keyword=" + document.getElementById("searchString").value;
	}

function ChangeSort(str, id, allItm) 
	{
	if(str!="")
		{
			var uriAd="http://www.proformancelogo.com/category/"+id+"/"+str;
			if(allItm!='0')
				uriAd+="/"+allItm;
		document.location.href = uriAd;
		}
	}

function over(id){
	document.getElementById(id).style.backgroundPosition="top right";
}

function out(id){
	document.getElementById(id).style.backgroundPosition="top left";
}

function CheckAddressDelete(id) 
	{
	if(alert("Are you sure? do you want to delete this address book entry?"))
		{
		document.location.href = "http://www.proformancelogo.com/address_book.php?delid="+id;
		}
	}

//Product Detail Page

function ChangePrice(imageID, attributeName, opt, index) 
	{
	var price=document.getElementById("price");
	//images
	eval ('str = '+attributeName+';');
	ids = str.split("::");
	len = ids.length;
		for (j=0;j<len;j++) {
			el = document.getElementById(ids[j]);
			el.className = "";
		}
	el = document.getElementById(imageID);
	el.className = "img_selected";
	//images       
    var form = document.form1;
	el = document.getElementById(opt);
    arr = el.options[index].value.split("::");
    val = arr[0];
    totalPrice=totalPrice - parseFloat(eval(el.name+"_prev"))+parseFloat(val);
	if(price!=null && price!='undefined')
		price.innerHTML=add_zeros(totalPrice);
	form.productPrice.value = totalPrice;
	eval(el.name+"_prev = "+val);
	el.options[index].selected = true;
	}

function ChangePriceAndImage(opt, val, attributeName) 
	{
	var price=document.getElementById("price");
    var form = document.form1;
    arr = val.split("::");
    val = arr[0];
    totalPrice=totalPrice - parseFloat(eval(opt.name+"_prev"))+parseFloat(val);
	price.innerHTML=add_zeros(totalPrice);
	form.productPrice.value = totalPrice;
	eval(opt.name+"_prev = "+val);
	imageID = arr[2];
	//images

	eval ('str = '+attributeName+';');
	ids = str.split("::");
	len = ids.length;
		for (j=0;j<len;j++) {
			el = document.getElementById(ids[j]);
			if (el) el.className = "";
		}
	if (el) el = document.getElementById(imageID);
	if (el) el.className = "img_selected";
	//images    
	}


function ChangePriceNoImages(opt, val)
	{
	var price=document.getElementById("price");
    var form = document.form1;
    arr = val.split("::");
    val = arr[0];
    totalPrice=totalPrice - parseFloat(eval(opt.name+"_prev"))+parseFloat(val);
	if(price!=null && price!='undefined')
		price.innerHTML=add_zeros(totalPrice);
	form.productPrice.value = totalPrice;
	eval(opt.name+"_prev = "+val);
	}

function add_zeros(a) 
	{
    if (a==Math.round(a)) a+=".00";
    else if (a*10==Math.round(a*10)) a+="0";
    return a;
	}

//Add validation 

function validate2()

	{

   	var errmsg = "";

   	var form = document.form1;   

   	document.form1.submit();

	}

	

function  ImageClick(imageID, attributeName) 

	{

	eval ('str = '+attributeName+';');

	ids = str.split("::");

	len = ids.length;

		for (j=0;j<len;j++) 

			{

			el = document.getElementById(ids[j]);

			el.className = "";

			}

		el = document.getElementById(imageID);

		el.className = "img_selected";

	}



function loop() 

	{

	a = 0;

	for(i=0; i<5000; i++) {a = a+5;}

	}



function ChangeImage(image_obj, width, height) 

	{

 	var form = document.form1;

 	if (document.images) 

		{

		form["MainImage"].src=eval(image_obj+".src");

		form["MainImage"].oldSrc=form["MainImage"].src;

		for(i=0; i<10000; i++)

		form.image_url.value = form["MainImage"].src;		

		 form.width.value = width;

		 form.height.value = height;

		}  //end if

	}

function OpenPopupWindow() 
	{
	var form = document.form1;
	path=form["MainImage"].src; 
	window.open(path, '_blank', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width='+form.width.value+',height='+form.height.value);
	}


function NewWindow(mypage, myname, w, h, scroll) 
	{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) 
		win.window.focus(); 
	}


//Cart Page

function validateCart()
	{
   var errmsg = "";
   var form = document.form1;   
   if(errmsg=="")
   		{
		document.form1.action="http://www.proformancelogo.com/cart.php?proceed=1";
		document.form1.submit();
      	//document.location.href="account_login.php";
   		}
   else
   		{
      	alert(errmsg);
      	return false;
   		}    
	}
	
//Account Pages

function CheckAddressDelete(id)

	{

	   if(confirm('Delete this address Entry'))

	   {

		  window.location.replace('http://www.proformancelogo.com/address_book.php?delid='+id)

	   }

	}

function MM_openBrWindow(theURL,winName,features) 
	{ //v2.0
  	window.open(theURL,winName,features);
	}

function RequestSample()
	{
		var msg="In order to request product samples you must be a registered user of our Website and be logged in.\n\n";
		msg+="TO REGISTER\nIt's easy, fast and free!  Simply click the 'OK' button to be taken to the account registration page.  Once you've registered you may return to the item to request a sample.\n\n";
		msg+="ALREADY REGISTERED?\nClick the 'OK' button and login to your account. Once you've logged in may return to the item to request a sample.";
		
		return confirm(msg);
		
	}