
function setCookie (name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + (expires ? "; expires=" + expires : "") + (path ? "; path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "secure" : "");
    document.cookie = curCookie;
}

function getCookie (name) {
    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie (name, path, domain) {
    if (getCookie(name))
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}

function rememberMe (f) {
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 180 * 24 * 60 * 60 * 1000);
    if (f.f_usr_login != undefined)
       setCookie('cook_f_usr_login', f.f_usr_login.value, now, '/', '', '');
    if (f.f_usr_pass != undefined)
       setCookie('cook_f_usr_pass', f.f_usr_pass.value, now, '/', '', '');
    
}

function forgetMe (f) {
    deleteCookie('cook_f_usr_login', '/', '');
    deleteCookie('cook_f_usr_pass', '/', '');
    f.cook_f_usr_login.value = '';
    f.cook_f_usr_pass.value = '';
}

function isRightStringFormat(p){ 
	var l = p.length; 
	var count=0; 
	for(var i=0; i<l; i++){ 
		var digit = p.charAt(i); 
		if((digit >= "0" && digit <= "9") || (digit >= "a" && digit <= "z") || (digit >= "A" && digit <= "Z") ){
			
		} else {
			count ++;
		}
	} 
	
	if(count > 0){
		return false; 
	}else{
		return true; 
	}
} 

function doZoom(size){
	//document.getElementById('zoom').style.fontSize=size+'px'
	var now = new Date();
	fixDate(now);
	now.setTime(now.getTime() + 180 * 24 * 60 * 60 * 1000);
	setCookie('fontsize', size, now, '/', '', '');

	var i =0;
	for(i = 1 ; i <= 100 ; i ++){
		var xx = "document.getElementById('zoom"+i+"')";
		var yy = eval(xx);
		if(yy != null){
			eval("document.getElementById('zoom"+i+"').style.fontSize='"+size+"px';");
		}
	}
}

function direct(url){
	document.location.href=url;
}

function addFav(url, statement){
	if (document.all){
		window.external.AddFavorite(url,statement);
	}
}

function popUpWindowWithScroll(url , height , width){
	window.open(url,"window","height="+height+", width="+width+", top=200, left=400, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no , target=_top");
}

function popUpWindow(url){
	window.open(url,"window","height=200, width=550, top=200, left=200, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no , target=_top");
}

function confirmAlert(direction, statement){
	if(confirm(statement)){
		window.location.href=direction;
	}else{
	}
}

function checkEmailStyle(email){ 
	var i=email.length;
	var temp = email.indexOf('@');
	var tempd = email.indexOf('.');
	if (temp > 1) {
		if ((i-temp) > 3){
			if ((i-tempd)>0){
				return true;
			}
		}
	}
	return false;
}

function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

function equals(var1 , var2) {
	if(trim(var1) != null && trim(var2) != null ){
		if(var1 == var2){
			return true;
		}else{
			return false;	
		}
	}else{
		return true;
	}
}

