function searchboxClick(inputID){
	document.getElementById(inputID).value="";
	document.getElementById(inputID).style.color="#252525";
}

function searchboxClickout(inputID) {
	document.getElementById(inputID).style.color="#A0A0A0";
}

function inputClickIn(inputID){
	document.getElementById(inputID).value="";
	document.getElementById(inputID).style.color="#252525";
}

function inputClickOut(inputID) {
	document.getElementById(inputID).style.color="#A0A0A0";
}

function updateStates(type) {
	var country = document.getElementById(type + '_country').value;
	var state_id_label = type + "_state_" + country;

	document.getElementById(type+'_state_US').style.display = 'none';
	document.getElementById(type+'_state_GB').style.display = 'none';
	document.getElementById(type+'_state_CA').style.display = 'none';
	document.getElementById(type+'_no_state').style.display = "none";

	if ( (country == 'GB') || (country == 'US') || (country == 'CA') ) {
		document.getElementById(state_id_label).style.display = "block";
	} else {
		document.getElementById(type+'_no_state').style.display = "block";
	}
	return true;
}

// ID elements must be separated by spaces.
// example: showHide(form_box title_box, content_box header_box footer_box);
function showHide(id_string_show,id_string_hide)
{
	id_array_show=id_string_show.split(" ");
	id_array_hide=id_string_hide.split(" ");

	//loop through ids you want to show
	if (id_array_show != "") {
		for(var i=0; i <id_array_show.length; i++) {
			id_box = document.getElementById(id_array_show[i]);
			if (id_box) {
				id_box.style.display="";
			}
		}
	}
	//loop through ids you want to hide
	if (id_array_hide != "") {
		for(var i=0; i <id_array_hide.length; i++) {
			id_box = document.getElementById(id_array_hide[i]);
			if (id_box) {
				id_box.style.display="none";
			}
		}
	}
}


// this is a one-off function and can only work for copying the values of
// billing information fields to the shipping information fields
function copyFields(form) {
  if(form.same_as_billing.checked == true) {
    form.shipping_full_name.value = form.full_name.value;
    form.shipping_line_one.value = form.bill_line_one.value;
    form.shipping_line_two.value = form.bill_line_two.value;
    form.shipping_city.value = form.bill_city.value;
    form.shipping_state.value = form.bill_state_US.value;

    form.shipping_postal_code.value = form.bill_postal_code.value;
    /* If more fields are used, just expand the parameters
       above to include the additional fields. */
  }
}

// The first value is the class that needs to be toggled
// ID elements must be separated by spaces.
// example: showHide('show', 'form_box title_box', 'content_box header_box footer_box');
// ***** CURRENTLY WILL ONLY WORK WITH TABS ********
function toggleClass(class_value1,class_value2,id_toggle_on,id_toggle_off) {

	id_array_on=id_toggle_on.split(" ");
	id_array_off=id_toggle_off.split(" ");

	//loop through ids you want to be the class_value
	if (id_array_on != "") {
		for(var i=0; i <id_array_on.length; i++) {
			id_box = document.getElementById(id_array_on[i])
			id_box.className=class_value1+" tab";
		}
	}
	//loop through ids you DO NOT want to be the class_value
	if (id_array_off != "") {
		for(var i=0; i <id_array_off.length; i++) {
			id_box = document.getElementById(id_array_off[i])
			id_box.className=class_value2+" tab";
		}
	}
}


// stuff for iframe, device selection and phone.php

function loadFrame(select_type,value,dtype,pop,product) {
	if (value == '------------------------------') return false;
	document.getElementById('phones').innerHTML = '<br /><img src="/images/icon-wait.gif" /> <br /><br /><br /><br /><br /><br /><br />';
	var strURL;
	var carrier_uid = 0;
	var manufacturer = "";
	var os = "";
	if (select_type == 'carrier') {
		carrier_uid = value;
		document.getElementById('manufacturer').selectedIndex = 0;
	}
	else if (select_type == 'manufacturer') {
		manufacturer = value;
		// removing since I am removing the carrier selection.  -PB, 2/2006
		//document.getElementById('carrier_uid').selectedIndex = 0;
	}
	else if (select_type == 'os') {
	//alert('os');
		os = value;
		// removing since I am removing the carrier selection.  -PB, 2/2006
		//document.getElementById('carrier_uid').selectedIndex = 0;
		if (os != "BlackBerry") document.getElementById('manufacturer').selectedIndex = 0;
	}

	// this line will determine how showdevices.php will query for devices
	strURL = '../showdevices.php?cuid='+carrier_uid+'&manf='+manufacturer+'&os='+os+'&dtype='+dtype+'&pop='+pop+'&product='+product;

	if (value == 'seePhone')
	{
		window.location = 'phones.php?dtype=phone';
	}
	if (value == 'seePDA')
	{
		window.location = 'phones.php?dtype=pda';
	}

	if ((value != 'seePDA') && (value != 'seePhone'))
	{
		if (document.frames) {
			document.frames('loadphones').location.replace(strURL);
		}
		else {
			window.frames['loadphones'].location.replace(strURL);
		}
	}
}


function iFrame2Div() {
        div = parent.document.getElementById('phones');
        frameDiv = parent.window.frames['loadphones'].document.getElementById('devices');
        html = frameDiv.innerHTML;
        div.innerHTML = '';
        div.innerHTML = html;
}


/*function loadFrame(sel,type) {
	document.getElementById('phones').innerHTML = '<br>Loading...';
	if (sel=="AT") sel="AT&amp;T WS";
	var strURL;
	 if (sel != "") {
		if (document.frames) {
			strURL = '../products/showdevices.php?m='+sel+'&type='+type;
			document.frames('loadphones').location.replace(strURL);
		}
		else {
			strURL = '../products/showdevices.php?m='+sel+'&type='+type;
			window.frames['loadphones'].location.replace(strURL);
		}
	 }
	 document.getElementById('deviceMan').value = sel;

	 /*if (type == "carrier")
	 {
		selInd = sel.split("!");
		document.getElementById('deviceMan').value = selInd[0];
	 }*/
/*}*/


function chooseMan(sel,dtype) {
	//window.location = "/products/phones.php?manf="+sel+"&dtype="+dtype;
	window.location = "phones.php?manf="+sel+"&dtype="+dtype;
}

function parentWin(url)
{
	window.opener.location.href = url;
	window.close();
}


//shopping cart functions

function validate_device()
{
	if ((document.check_device.device.selectedIndex == 0) & (document.check_device.skip.checked != true ))
	{
		alert("Please select a device from the list");
		document.check_device.device.focus();
		return false;
	}
	return true;
}




function popup(url, windowname)
{
if (! window.focus)return true;
window.open(url, "handmarkstorehelp", 'width=400,height=600,scrollbars=1');
}

function popupVerisign(url)
{
sealWin = window.open(url,"win",'toolbar=0,location=1,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=550,height=450');
self.name = "mainWin";
}

function popVerisign(url) {
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=600,height=450');
	self.name = "parentWindow";
}

function popup2(url, windowname, width, height) {
	//setting defaults
	if (url == null || url == ""){
		return;
	} else {
		if (windowname == null) {
			windowname = "Handmark";
		}
		if (width == null) {
			width = 800;
		}
		if (height == null) {
			height = 600;
		}

		/*var scrollbar = 1;var status = 1;var toolbar = 1;var location = 1;var menubar = 1;var resizable = 1;*/
		window.open(url,windowname,'width='+width+',height='+height+',toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');

	}
}



// splash image swap
 var aryImages = new Array(20);

  aryImages[189] = "/assets/site_images/splash/device189.jpg";
  aryImages[244] = "/assets/site_images/splash/device244.jpg";
  aryImages[257] = "/assets/site_images/splash/device257.jpg";
  aryImages[292] = "/assets/site_images/splash/device292.jpg";
  aryImages[300] = "/assets/site_images/splash/device300.jpg";
  aryImages[307] = "/assets/site_images/splash/device307.jpg";
  aryImages[308] = "/assets/site_images/splash/device308.jpg";
  aryImages[345] = "/assets/site_images/splash/device345.jpg";
  aryImages[350] = "/assets/site_images/splash/device350.jpg";
  aryImages[359] = "/assets/site_images/splash/device359.jpg";
  aryImages[360] = "/assets/site_images/splash/device360.jpg";
  aryImages[364] = "/assets/site_images/splash/device364.jpg";
  aryImages[372] = "/assets/site_images/splash/device372.jpg";
  aryImages[374] = "/assets/site_images/splash/device374.jpg";
  aryImages[376] = "/assets/site_images/splash/device376.jpg";
  aryImages[420] = "/assets/site_images/splash/device420.jpg";
  aryImages[467] = "/assets/site_images/splash/device467.jpg";
  aryImages[469] = "/assets/site_images/splash/device469.jpg";
  aryImages[476] = "/assets/site_images/splash/device476.jpg";
  aryImages[478] = "/assets/site_images/splash/device478.jpg";
  aryImages[479] = "/assets/site_images/splash/device479.jpg";
  aryImages[480] = "/assets/site_images/splash/device480.jpg";
  aryImages[484] = "/assets/site_images/splash/device484.jpg";
  aryImages[486] = "/assets/site_images/splash/device486.jpg";
  aryImages[505] = "/assets/site_images/splash/device505.jpg";
  aryImages[560] = "/assets/site_images/splash/device560.jpg";
  aryImages[566] = "/assets/site_images/splash/device566.jpg";
  aryImages[574] = "/assets/site_images/splash/device574.jpg";
  aryImages[620] = "/assets/site_images/splash/device620.jpg";
  aryImages[653] = "/assets/site_images/splash/device653.jpg";
  aryImages[654] = "/assets/site_images/splash/device654.jpg";
  aryImages[668] = "/assets/site_images/splash/device668.jpg";
  aryImages[695] = "/assets/site_images/splash/device695.jpg";
  aryImages[728] = "/assets/site_images/splash/device728.jpg";
  aryImages[727] = "/assets/site_images/splash/device727.jpg";
  aryImages[967] = "/assets/site_images/splash/device967.jpg";


  aryImages[970] = "/assets/site_images/splash/device970.jpg";
  aryImages[724] = "/assets/site_images/splash/device724.jpg";
  aryImages[955] = "/assets/site_images/splash/device955.jpg";
  aryImages[820] = "/assets/site_images/splash/device820.jpg";
  aryImages[736] = "/assets/site_images/splash/device736.jpg";
  aryImages[726] = "/assets/site_images/splash/device726.jpg";
  aryImages[769] = "/assets/site_images/splash/device769.jpg";
  aryImages[679] = "/assets/site_images/splash/device679.jpg";
  aryImages[964] = "/assets/site_images/splash/device964.jpg";
  aryImages[975] = "/assets/site_images/splash/device975.jpg";
  aryImages[737] = "/assets/site_images/splash/device737.jpg";
  aryImages[844] = "/assets/site_images/splash/device844.jpg";
  aryImages[794] = "/assets/site_images/splash/device794.jpg";

  aryImages[972] = "/assets/site_images/splash/device972.jpg";
  aryImages[1002] = "/assets/site_images/splash/device1002.jpg";
  aryImages[984] = "/assets/site_images/splash/device984.jpg";
  aryImages[989] = "/assets/site_images/splash/device989.jpg";
  aryImages[976] = "/assets/site_images/splash/device976.jpg";





// preload, but takes too long to download all those images
//  for (i=0; i < aryImages.length; i++) {
//    var preload = new Image();
//    preload.src = aryImages[i];
//  }

  function swap(imgIndex) {
    document['splash_image'].src = aryImages[imgIndex];
  }


function submitForm(form_name) {
	document.forms[form_name].submit();
}





//NewsLetter Functions
function nl_uncheck(newsletter_list) {
	//alert(newsletter_list);
	var newsletter_array = newsletter_list.split(",");

	if (document.getElementById("no_newsletter").checked == true  ) {
		for(i=0;i<newsletter_array.length;i++){
			//alert(newsletter_array[i]);
			document.getElementById(newsletter_array[i]).checked = false;
		}
	}
}

function changeDays(month)
{
	if (month == 2 || month == 4 || month == 6 || month == 9 || month == 11) {
		document.forms['subscribe'].birth_day.options[30] = new Option("30",30);
		document.forms['subscribe'].birth_day.options[31] = null;
		if (month==2) {
			document.forms['subscribe'].birth_day.options[30] = null;
		}
	} else {
		document.forms['subscribe'].birth_day.options[30] = new Option("30",30);
		document.forms['subscribe'].birth_day.options[31] = new Option("31",31);
	}
}
