function popModal(page,w,h) {

	if (window.showModalDialog) {

		window.showModalDialog(page,"name","dialogWidth:"+w+"px;dialogHeight:"+h+"px");

	} else {

		window.open(page,'name','height='+h+',width='+w+',toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,modal=yes');

	}

}





var ns6=document.getElementById&&!document.all?1:0

var head="display:''"

var folder=''

function expandit(curobj){

folder=ns6?curobj.nextSibling.nextSibling.style:document.all[curobj.sourceIndex+1].style

if (folder.display=="none")

folder.display=""

else

folder.display="none"

}





function getPrintingPrice(qty, seatType,duration_id, index,total){    // prateek



  var xmlHttp;

  try{// Firefox, Opera 8.0+, Safari

    xmlHttp=new XMLHttpRequest();

  }

  catch (e){// Internet Explorer

    try{

      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

    }

    catch (e){

      try{

        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

      }

      catch (e){

        alert("Your browser does not support AJAX!");

        return false;

      }

    }

  }

  

  xmlHttp.onreadystatechange=function(){

    if(xmlHttp.readyState==4){

            eval("document.frmCheckout.temp").value = xmlHttp.responseText;

	        //alert(xmlHttp.responseText);

            changeAmountsUpdate(index,total);

    }

  }

 //alert("qty" + qty + "seatType" + seatType+ "duration_id" + duration_id);

  xmlHttp.open("GET","get_price.asp?qty="+qty + "&seatType="+seatType+ "&duration_id="+duration_id,true);

  xmlHttp.send(null);

}



function changeAmount(whichOne) {

	//alert('hello world');

    seat_qty = 0;

	total = 1;

	i=1;

	seat_qty = eval("document.frmCheckout.seat_qty").value;
	//alert();
    updateProductInCart(whichOne, total);

            

   // var tempTotal = parseFloat(grandTotal)  + parseFloat(imageTotal) 

	//tempTotal =  CommaFormatted(tempTotal.toFixed(2));

	

   // document.frmCheckout.sub_total.value = tempTotal;

   // document.getElementById('grand_total').innerHTML = '<span style=color:#000000>$' + tempTotal + '</span>';

	//setCookie("cart_total",tempTotal,1);

	

};



function updateProductInCart(i,total){

    //alert(i)

    total =  1 //document.frmCheckout.total.value;

    cat_id = 1;

    index = i;

	i=1;

	if (eval("document.frmCheckout.seat_qty")) { 	
		//alert("in if");
		seatQty = eval("document.frmCheckout.seat_qty").value;
		seatType = eval("document.frmCheckout.seatType").value;
		duration_id = eval("document.frmCheckout.timeframeDisplay").value;
    	getPrintingPrice(seatQty, seatType, duration_id, index, total);
	//alert(total);
	}

};



function changeAmountsUpdate(i,total) {



	temp = eval("document.frmCheckout.temp").value
	seat_qty = eval("document.frmCheckout.seat_qty").value
	//alert(temp);
	var mySplitResult = temp.split("|");

	for(i = 0; i < mySplitResult.length; i++){

		//alert('mySplitResult===>' + mySplitResult[i]);

		if (i==0) {

		 seat_rate = mySplitResult[i];

		}

		if (i==1) {

		 billing_id = mySplitResult[i];
	//alert(seat_rate);
		}


		//savings = " :: <font color='#006600' size='3'><b> Savings of " + mySplitResult[i] + "%</b></font>";

			

	

	}


  

	subTotal = parseFloat(seat_rate) * parseFloat(seat_qty);

	

    total = parseFloat(subTotal);
	
    seatTotal = parseFloat(seat_rate);

    

	//document.frmCheckout['details_1'].value =  durationtext;	

	//document.frmCheckout['timeframe_1'].value =  id;
	document.frmCheckout['seatRate'].value =  seat_rate;	
	document.frmCheckout['timeframe'].value =  billing_id;	
	document.frmCheckout['total'].value =  total.toFixed(2);	
	document.getElementById('price_display').innerHTML = '<span class=fbsmtxt>$' + seat_rate + '</span>';
    document.getElementById('grand_total_display').innerHTML = '<span class=fbsmtxt>$' + total.toFixed(2) + '</span>';



};





//new expand code for menu



function show_hide(tblid, show) {

        if (tbl = document.getElementById(tblid)) {

            if (null == show) show = tbl.style.display == 'none';

            tbl.style.display = (show ? '' : 'none');

        }

    }









function copyBillToInfo()

{

    



    //alert("here" + document.frmCheckout.sameShipping.checked);

    if(document.frmCheckout.sameShipping.checked) {

        document.frmCheckout.saddress.value = document.frmCheckout.address.value;

        document.frmCheckout.saddress2.value = document.frmCheckout.address2.value;

        document.frmCheckout.scity.value = document.frmCheckout.city.value;

        document.frmCheckout.sstate.value = document.frmCheckout.state.value;

        document.frmCheckout.spostalcode.value = document.frmCheckout.postalcode.value;

        document.frmCheckout.scountry.value = document.frmCheckout.country.value;

        document.frmCheckout.sphone.value = document.frmCheckout.phone.value;

    }else{

        document.frmCheckout.saddress.value = "";

        document.frmCheckout.saddress2.value = "";

        document.frmCheckout.scity.value = "";

        document.frmCheckout.sstate.value = "";

        document.frmCheckout.spostalcode.value = "";

        document.frmCheckout.scountry.value = "";

        document.frmCheckout.sphone.value = "";

    }

}







function isNumberKey(myfield, e, dec)

{

    var key;

    var keychar;

    

    if (window.event)

      key = window.event.keyCode;

    else if (e)

      key = e.which;

    else

      return true;

    keychar = String.fromCharCode(key);

    

    // control keys

    if ((key==null) || (key==0) || (key==8) || 

        (key==9) || (key==13) || (key==27) )

      return true;

    

    // numbers

    else if ((("0123456789").indexOf(keychar) > -1))

      return true;

    

    // decimal point jump

    else if (dec && (keychar == "."))

      {

      myfield.form.elements[dec].focus();

      return false;

      }

    else

      return false;

}





function jm_phonemask(t)

{var patt1 = /(\d{3}).*(\d{3}).*(\d{4})/;

var patt2 = /^\((\d{3})\).(\d{3})-(\d{4})$/;

var str = t.value;

var result;

if (!str.match(patt2))

{result = str.match(patt1);

if (result!= null)

{t.value = t.value.replace(/[^\d]/gi,'');

str = '(' + result[1] + ') ' + result[2] + '-' + result[3];

t.value = str;

}else{

if (t.value.match(/[^\d]/gi))

t.value = t.value.replace(/[^\d]/gi,'');

}}}



function jm_zipmask(t){

    var numaric = t.value;

    for(var j=0; j<numaric.length; j++)

        {

          var alphaa = numaric.charAt(j);

          var hh = alphaa.charCodeAt(0);

          //hh > 47 && hh<59 //small letters

          //96 && hh<123  //special characters

          //(hh > 47 && hh<91)  small/cap letters 65-91

          if((hh > 47 && hh<91) ||  (hh > 96 && hh<123)) {

          }else{

            alert("Please enter Alphanumeric characters only.");

              document.forms[0].postalcode.value="";        

            return false;

          }

        }

//alert("Your Alpha Numeric Test Passed");

return false;        

}



function ValidateListForm()

{

	if (document.securityForm.filename.value == "") {

		alert("Please upload your addresss List.");

		document.securityForm.filename.focus();

		return false;

	}

	/*********************************************************/	

	

				

	return true;

}





function ValidateForm()

{



    total =  document.frmCheckout.total.value;

    addressShipQty = 0;

    ship_to_store_qty =0;

    

    var isLess = false;

    var z = 1;



    for (var i=0; i < total; i++)

        {    

            

            addressShipQty = eval("document.frmCheckout.printing_qty_"+i).value;    

            ship_to_store_qty = eval("document.frmCheckout.shipping_qty_"+i).value;            

            temp =  parseInt(ship_to_store_qty) + parseInt(addressShipQty)

            

            if (addressShipQty < 500) { 

                isLess = true;

                break;

            }

            

                    

            

        }

        

        

        if (isLess) {

            alert('You must enter at least a 500 printing quantity.');

            return(false);

        }    

        

    return true;

}





function ValidateShipping()

{



    total =  document.frmCheckout.total.value;

    for (var i=0; i < total; i++)

        {    

            

            ship_to_store_qty = eval("document.frmCheckout.ship_to_store_qty_"+i).value;

            shipping_qty = eval("document.frmCheckout.shipping_qty_"+i).value;    

            temp = ship_to_store_qty - shipping_qty;        

            

            if (shipping_qty < ship_to_store_qty) { 

                isLess = true;

                break;

            }

        }

        

        

        if (isLess) {

            alert('You have ' + temp + ' quantity to still use');

            return(false);

        }    

        

    return true;

}



function selectShipping() {



    total =  document.frmCheckout.total.value;

    temp3 = "hello";

    

        

            

            

    var isOneChecked = false;

        for (var i=0; i < total; i++)

        {

            

            temp = eval("document.frmCheckout.select_"+i).checked;

            

            if(temp){

                isOneChecked = true;

                break;

            }

        }

    

        if (!isOneChecked) {

            alert('You must choose a user to process.');

            return(false);

        }else{

            document.getElementById('sa_'+i).innerHTML = '<span style=color:#000000> ' + temp3  + '</span>';

            document.getElementById('sb_'+i).innerHTML = '<span style=color:#000000> ' + temp3  + '</span>';

            document.getElementById('sc_'+i).innerHTML = '<span style=color:#000000> ' + temp3  + '</span>';

            return(true);

        }

    

        return false;

    

}



function changeShipping() {



    

    total =  document.frmCheckout.total.value;

    grandTotal = 0;

   

    //alert(total);



    

        for (var i=0; i < total; i++) 

        {

        

            //alert(i);

            ship_to_store_qty = eval("document.frmCheckout.ship_to_store_qty_"+i).value;

            shipping_qty = eval("document.frmCheckout.shipping_qty_"+i).value;

            temp = ship_to_store_qty - shipping_qty;

            

            //document.getElementById("div_amount").innerHTML = "andrea";

            document.getElementById('aa_'+i).innerHTML = '<span style=color:#000000>' + temp + '</span>';

            

    

        }

            

            document.frmCheckout.sub_total.value = tempTotal.toFixed(2);

            document.getElementById('grand_total').innerHTML = '<span style=color:#000000>$' + tempTotal.toFixed(2) + '</span>';

}









function changeText(){

    document.getElementById('boldStuff').innerHTML = 'Fred Flinstone';

    document.getElementById('boldStuff2').innerHTML = 'Fred';

}



function ValidateCartImage () {



    total =  document.frmImageCheckout.total.value;

    alert ("total" + total);

    var isOneChecked = false;

        for (var i=0; i < total; i++)

        {

            

            temp = eval("document.form.res_"+i.checked);

            alert(temp);

            if(document.form.res_[i].checked){

                isOneChecked = true;

                break;

            }

        }

    

        if (!isOneChecked) {

            alert('You must choose a user to process.');

            return(false);

        }

}







function formchecker(theForm) {

    var correct = 0;

    var allvalid = true;

    var alertstr = "";

    var validstr = "All form data is correct.\n\n";

    var num_of_elements = frmImageCheckout.length;

    var radio_selected = false;

    var checkbox_selected = false;

    total =  document.frmImageCheckout.total.value;

    total = total-1;

    

    for (var i=0; i<num_of_elements; i++) {

            var theElement = theForm.elements[i];

            var element_type = theElement.type;

            var element_name = theElement.name;

            var element_value = theElement.value;

            var    allvalid = true;



            // Check Radio buttons ...

            if (element_type == "radio" ) {

                if (theElement.checked == true) {

                    radio_selected = true;

                    //alert (radio_selected);

                    correct ++;

                    validstr += "From form element '" + element_name + "' you selected the \"" + element_value + "\" button.\n\n";

                }

            }

    }



    

    /*if (radio_selected == false ) {

        alertstr += "There are no radio buttons checked.\n\n";

        allvalid = false;

    }*/

    

    /*if (checkbox_selected == false) {

        alertstr += "There are no Checkboxes selected.\n\n";

        allvalid = false;

    }*/



// All elements checked - now determine if form is OK ...

    /*if (allvalid) {

        alert (validstr);

        alert ("Who's a clever-clogs then?\n\n        %%%\n    / o    o \\\n    @  \\/  @\n      \\  ~~  /\n        ###");

        return false;

    } else {

        alert (alertstr);

        return false;

    }*/

    

    

    //alert (correct + "--" + total);

    

    //if (correct >= total) {    

    //alert (validstr);

    if (correct != 0) {    

    // place any other field validations that you require here

    theForm.submit(); // this line submits the form after validation    

    } else {

        alert ("Choose either High or Low Res for your image purchase.\n\n");

        return false;

    }    

}







  if(window.attachEvent)

    window.attachEvent("onload",setListeners);



  function setListeners(){

    inputList = document.getElementsByTagName("INPUT");

    for(i=0;i<inputList.length;i++){

      inputList[i].attachEvent("onpropertychange",restoreStyles);

      inputList[i].style.backgroundColor = "";

    }

    selectList = document.getElementsByTagName("SELECT");

    for(i=0;i<selectList.length;i++){

      selectList[i].attachEvent("onpropertychange",restoreStyles);

      selectList[i].style.backgroundColor = "";

    }

  }



  function restoreStyles(){

    if(event.srcElement.style.backgroundColor != "")

      event.srcElement.style.backgroundColor = "";

  }

  

  

  

function changeimage1()

{

document.image1.src="../images/navlines3.gif";

}



function hideimage1()

{

document.image1.src="../images/navlines2.gif";



}









function ValidateShippingQty()

{



	var isComplete = false;

	total =  document.frmCheckout.total.value;

	

	for (var i=0; i < total; i++)

		{	

			

			shipping_qty = eval("document.frmCheckout.shipping_qty_"+i).value;	

				

			if (shipping_qty < 1) { 

				isComplete = true;

				break;

			}

						

			

			

		}

		

		

		if (isComplete) {

			alert('Please enter how many stores you need these shipped to.');

			 return(false);

		}	

		

		

	return true;

}





function ValidateShipping()

{



	var isLess = false;

	var isComplete = false;

	total =  document.frmCheckout.total.value;

	//alert("total" + total);

	subTotal = 0;

	

	for (var i=0; i < total; i++)

		{	

			alert("i" + i);

			totalMain = 0;

			subTotal = 0;

			shipping_qty = 0;

			ship_to_store_qty = eval("document.frmCheckout.ship_to_store_qty_"+i).value;

			final_address_id = eval("document.frmCheckout.final_address_id_"+i).value;	

			totalMain = eval("document.frmCheckout.totalMain_"+i).value;	

			

			//alert("totalMain==>" + totalMain);			

			for (var x=0; x < totalMain; x++)

				{	

					

					shipping_qty = eval("document.frmCheckout.shipping_qty_"+x).value;	

					subTotal +=  parseInt(shipping_qty);

					temp = ship_to_store_qty - subTotal;

					alert("subTotal " + x + "--"  +  parseInt(shipping_qty));	

					//alert(total);

					/*

					if (final_address_id == 0) { 

						isComplete = true;

						break;

					}

					*/

					

				}

				

				//alert("subTotal " + subTotal);	

				

			

		}

		

			

			

			

		if (subTotal < ship_to_store_qty) { 

				alert('You have ' + temp + ' quantity to still use');

				 return(false);

			}	

		

		if (isComplete) {

			alert('You need to select your Shipping Address. \n\nCheck the checkbox next to the Address you need to assign.\n\nNow click the burgandy "select" hyperlink located to your right under "SHIPPING ADDRESSES" to choose the address you want.');

			 return(false);

		}

		

		

	return true;

}



function selectShipping(a) {



	total =  document.frmCheckout.total.value;

	total2 =  document.getAddresses.total.value;

	temp3 = "hello";

	

	shipping_id =  eval("document.getAddresses.shipping_id_"+a).value;

	address = eval("document.getAddresses.address_"+a).value; 

	city = eval("document.getAddresses.city_"+a).value; 

	state = eval("document.getAddresses.state_"+a).value; 

			

	var counter = 0;	

	var isOneChecked = false;

		for (var i=0; i < total; i++)

		{

			

			

			temp = eval("document.frmCheckout.select_"+i).checked;

			

			 if(temp){

				isOneChecked = true;

				counter = i;

				break;

	

			 }

		}

	

		if (!isOneChecked) {

			alert('You must choose a user to process.');

			return(false);

		}else{

			document.getElementById('sa_'+counter).innerHTML = '<span style=color:#000000> ' + address  + '</span>';

			document.getElementById('sb_'+counter).innerHTML = '<span style=color:#000000> ' + city  + '</span>';

			document.getElementById('sc_'+counter).innerHTML = '<span style=color:#000000> ' + state  + '</span>';

			document.frmCheckout['final_address_id_'+counter].value = shipping_id;

			document.frmCheckout['select_'+counter].checked =  false;

			return(false);

		}

	

		return false;

	

}



function formSubmitShipping(target){

	//alert("here" + document.forms[0].promoCode.value);

	if(target == 0) document.getAddresses.action="checkout2.php?step=1";

	if(target == 1) {

		document.getAddresses.action="checkout2.php";

	}

	

}





function changeShipping() {



	

	total =  document.frmCheckout.total.value;

	grandTotal = 0;

	

	//alert(total);



	

		for (var i=0; i < total; i++) 

		{

		

			//alert(i);

			ship_to_store_qty = eval("document.frmCheckout.ship_to_store_qty_"+i).value;

			shipping_qty = eval("document.frmCheckout.shipping_qty_"+i).value;

			

			temp = ship_to_store_qty - shipping_qty;

			

			if (temp == 0) {

				temp = "complete";

				document.getElementById('aa_'+i).innerHTML = '<span style=color:#124c04>' + temp + '</span>';

			}else if (temp < 0) {	

				temp = "complete";

				document.getElementById('aa_'+i).innerHTML = '<span style=color:#124c04>' + ship_to_store_qty + '</span>';

				document.frmCheckout['shipping_qty_'+i].value = ship_to_store_qty;

			}else{

				document.getElementById('aa_'+i).innerHTML = '<span style=color:#4c0417>' + temp + '</span>';

			}

			//document.getElementById("div_amount").innerHTML = "andrea";

			

			

	

		}

			

			document.frmCheckout.sub_total.value = tempTotal.toFixed(2);

		 	document.getElementById('grand_total').innerHTML = '<span style=color:#000000>$' + tempTotal.toFixed(2) + '</span>';

}



function setCookie(c_name,value,expiredays)

{

	var exdate=new Date();

	exdate.setDate(exdate.getDate()+expiredays);

	document.cookie=c_name+ "=" +escape(value)+

	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());

}



function CommaFormatted(amount)

{

	var delimiter = ","; // replace comma if desired

	var a = amount.split('.',2)

	var d = a[1];

	var i = parseInt(a[0]);

	if(isNaN(i)) { return ''; }

	var minus = '';

	if(i < 0) { minus = '-'; }

	i = Math.abs(i);

	var n = new String(i);

	var a = [];

	while(n.length > 3)

	{

		var nn = n.substr(n.length-3);

		a.unshift(nn);

		n = n.substr(0,n.length-3);

	}

	if(n.length > 0) { a.unshift(n); }

	n = a.join(delimiter);

	if(d.length < 1) { amount = n; }

	else { amount = n + '.' + d; }

	amount = minus + amount;

	return amount;

}

// end of function CommaFormatted()

