function getCookie(c_name)
{
	if (document.cookie.length > 0)
	{
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
		{ 
			c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
				return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}

function setCookie(name, value)
{
	var exdate = new Date();
	var expiredays = 365;
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie = name + "=" + escape(value)+	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function checkCookie()
{
	var name = getCookie('name');
	
	try{
		document.getElementById(name).className = "menu_over";
	
	}
	catch(e) { }

	
	setCookie('name',name, 365);
}
function changebg(catid)
{
	catid.className="top_buttons_over";
}
function callbackbg(catid){

	catid.className="orangeboldtext";
}
function changebg2(catid)
{
catid.className="top_buttons";
}

 
function stateUS()
{
	box = document.a.statenavi;
	//alert(box);
	destination = box.options[box.selectedIndex].value;
	//alert(destination);
	if (destination) location.href = destination;
}
function stateuk()
{
	box = document.a.statenaviuk;
	//alert(box);
	destination = box.options[box.selectedIndex].value;
	//alert(destination);
	if (destination) location.href = destination;
}

function canada()
{
	box = document.a.canadnavi;
	//alert(box);
	destination = box.options[box.selectedIndex].value;
	//alert(destination);
	if (destination) location.href = destination;
}
function statespain()
{
 	box = document.a.statenavispain;
	 //alert(box);
	destination = box.options[box.selectedIndex].value;
	//alert(destination);
	if (destination) location.href = destination;
}

function go()
{
	box = document.a.navi;
	//alert(box);
	destination = box.options[box.selectedIndex].value;
	//alert(destination);
	if (destination) location.href = destination;
}
function selectAvatar(i)
{
	document.getElementById("newSelectedAvatar").src = "system/cache/avatar/" + i;
	document.getElementById("img").value = i;
}
function editImages(){
		var number = parseInt(document.editClassifieds.store.value);
		var newnum = parseInt(document.editClassifieds.newStore.value);
 		if(newnum < 5){
			var newnumber = number + 1;
			contents = '<table width="100%" border="0" cellspacing="2" cellpadding="0">';
			contents = contents + '<tr><td width="60">Image'+newnum+' </td>';
			contents = contents + '<td><input name="image'+number+'" type="file" id="image'+number+'" /></td>';
			contents = contents + '</tr></table><div id="img'+newnumber+'" </div>';
			document.getElementById('img'+number).innerHTML = contents;
			number++;
			document.editClassifieds.store.value = number;
			newnum++;
			document.editClassifieds.newStore.value= newnum;
		}
		else {
			alert("You Have Excceded The Maximum Nos");
		}
}
function deleteConfirm(loc) {
 	locsplit=loc.split('&');
 	if(locsplit[0] == '?L=users.edit'){
  		if(confirm("Are you sure to delete this image?"))
 		location.replace(loc);
	}
}
var clicksArray = new Array()
function populatedFieldClick(fieldName) {
  	if (!clicksArray[fieldName]) {
	  clicksArray[fieldName] = true;
	  document.getElementById(fieldName).value = '';
	}
}
function checkCatField(){
	if(document.catForm.title.value==''){
		alert("Please enter category name");
		document.catForm.title.focus();
		return false;
	}
	return true;
}

function addImages(){
		var number = parseInt(document.addclassifieds.store.value);
		if(number < 5){
			var newnumber = number + 1;
			contents = '<table width="100%" border="0" cellspacing="2" cellpadding="0">';
			contents = contents + '<tr><td width="200">Image'+number+' </td>';
			contents = contents + '<td><input name="image'+number+'" type="file" id="image'+number+'" /></td>';
			contents = contents + '</tr></table><div id="img'+newnumber+'" </div>';
			document.getElementById('img'+number).innerHTML = contents;
			number++;
			document.addclassifieds.store.value = number;
		}
		else {
			alert("You Have Excceded The Maximum Nos");
		}
	}
 
 
  function replayM(rVal){
  
  if(rVal.value=='A'){
  document.getElementById('OC').style.display="block";
   }
   else{
   	 document.getElementById('OC').style.display="none";
   }
   }