

function stripQuotes(word) {
str = word;
while(str.indexOf("'") != -1) {
num = len(str);
str = str.substring(0, str.indexOf("'")-1) + str.substring(str.indexOf("'")+1, num);
}
return str;
}


function stripit(x){
x = x.replace(/['"]/g,'');
};


function showid(varid) {
document.getElementById(varid).style.display = 'inline'
document.getElementById(varid).style.visibility = 'visible'
}

function hideid(varid) {
document.getElementById(varid).style.display = 'none'
document.getElementById(varid).style.visibility = 'hidden'
}

function showid_block(varid) {
document.getElementById(varid).style.display = 'block'
document.getElementById(varid).style.visibility = 'visible'
}


function changedata(what) {
document.getElementById('txtChanged').value = stripQuotes(document.getElementById('txtChanged').value + what + '. ');
}


function swp(id,src) {
document.getElementById(id).src = src
}


function checkdel(what) {
	
	if (confirm(stripQuotes(what))==true){
	return true;
	}else{
	return false;
	}

}


function Left(str, n)
{
   if (n <= 0)
         return "";
   else if (n > String(str).length)
         return str;
   else
         return String(str).substring(0,n);
}


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}



function madechange(catid,varb2,varb3){
if (document.getElementById('lastupdatedid').value!=''){
if (document.getElementById('lastupdatedid').value!=catid){
response = confirm('You have not saved the changes that you have made to the last category (' + document.getElementById('haschangedcategory').value + ')..\n\nClick OK to save changes to ' + document.getElementById('haschangedcategory').value + '.\n\nClick cancel to continue and discard changes.');

	if (response==true){
	document.getElementById('frm'+document.getElementById('lastupdatedid').value).submit()
	return true;
	}else{
	//discard
	document.getElementById('butsave'+document.getElementById('lastupdatedid').value).className = 'cmsbut';
	document.getElementById('lastupdatedid').value = '';
	document.getElementById('haschanged').value = '';
	return false;
	}
}
}

document.getElementById('lastupdatedid').value = catid;
document.getElementById('butsave'+catid).className = 'cmsbutr';
document.getElementById('haschangedcategory').value = varb2;
document.getElementById('haschanged').value = document.getElementById('haschanged').value + " - " + varb3 + "\n";
}


function checkforchanges(){


	if (document.getElementById('haschanged').value!=''){
	
		response2 = confirm('You have made changes to..\n\n' + document.getElementById('haschangedcategory').value + '\n' + document.getElementById('haschanged').value + '\nClick OK to navigate away and DISCARD changes.\n\nTo save changes, click cancel and then the appropriate save button.');
	
		if (response2==true){
		document.getElementById('oktogo').value = '';
		}else{
		document.getElementById('oktogo').value = 'salad';
		return false;
		}
	}

}





function styleon(trid) {
    document.getElementById(trid).className = 'tbsum'
}

function styleoff(trid) {
    document.getElementById(trid).className = 'none'
}

function cclass(idi, cls) {
    document.getElementById(idi).className = cls
}

