/*
	 **
     * ozLancer
     *
     * A Freelance Service Marketplace
     *
     * @package			ozLancer
     * @author			Sam Georges
     * @copyright		Copyright (c) 2009
     * @license			
     *
      ---------------------------------------------------------------------------
*/
function populateStates(selected,mychoice,state) {
	document.step1_form.elements[state].selectedIndex = 0;
	var nochoice = 1;
	if ( eval(selected+"_array") ){
		var selectedArray = eval(selected+"_array");
		while (selectedArray.length < document.step1_form.elements[state].options.length) {
			document.step1_form.elements[state].options[(document.step1_form.elements[state].options.length - 1)] = null;
		}
		eval("document.step1_form.elements[state].options[0]=" + "new Option('--')");
		document.step1_form.elements[state].options[0].value="0";
		for (var i=1; i < selectedArray.length; i++) {
			var id = selectedArray[i].substring(0,selectedArray[i].indexOf(":"));
			var val = selectedArray[i].substring(selectedArray[i].indexOf(":")+1, selectedArray[i].length);
			document.step1_form.elements[state].options[i]=new Option(val);
			document.step1_form.elements[state].options[i].value=id;
			if (id == mychoice){
				document.step1_form.elements[state].selectedIndex = i;
				nochoice = 0;
			}
		}
	}else{
		document.step1_form.elements[state].options[(document.step1_form.elements[state].options.length - 1)] = null;
		eval("document.step1_form.elements[state].options[0]=" + "new Option('--')");
		document.step1_form.elements[state].options[0].value="0";
	}
	if (nochoice){
		document.step1_form.elements[state].selectedIndex = 0;
	}
}

function updateReigonAnswer(id) {
	var state = 'state'+id;
	var country = 'country'+id;
	var answer = 'answer'+id;	
	document.step1_form.elements[answer].value = document.step1_form.elements[state].value + '::' + document.step1_form.elements[country].value;
    /*$('answer'+id).value = $('state'+id).value + '|' + $('country'+id).value;*/
}


/* This will hide and show the custom id input  */
function updateCustomAnswer(input) {
	if (input == "custom") {
		document.getElementById('custom_answer').style.visibility = "visible";	
		document.getElementById('custom_answer').style.display = "inherit";			
	} else {
		document.getElementById('custom_answer').style.visibility = "hidden";
		document.getElementById('custom_answer').style.display = "none";		
	}
}

function bookmarksite(title,url){
if (window.sidebar) // firefox 	window.sidebar.addPanel(title, url, "");
	alert('Press Ctrl+D to add to your Firefox Bookmarks');
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}
