﻿function link_mode(obj, id) {
   var linkList = document.getElementById(id).getElementsByTagName("a");
   for (i = 0; i < linkList.length; i++) {
      linkList[i].className = "no-l";
   }
   obj.className = "yes-l";
}


function link_mode2(obj, id) {
   var linkList = document.getElementById(id).getElementsByTagName("a");
   for (i = 0; i < linkList.length; i++) {
      linkList[i].className = "no-l";
   }
   obj.className = "yes-l2";
}


function link_mode3(obj, id) {
   var linkList = document.getElementById(id).getElementsByTagName("a");
   for (i = 0; i < linkList.length; i++) {
      linkList[i].className = "no-l";
   }
   obj.className = "yes-l3";
}


function connect(url,data,id,load) {
    var xmlhttp=false;

    if(!xmlhttp) { 
		if (window.XMLHttpRequest)
			xmlhttp=new XMLHttpRequest(); 
		else if (window.ActiveXObject)
			xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');	
	} else if(window.XMLHttpRequest){  
	xmlHttp = new XMLHttpRequest(); 
} 
		xmlhttp.open('POST', url, true);
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlhttp.onreadystatechange = function() {
        if(xmlhttp.readyState==4 && xmlhttp.status == 200) {
					document.getElementById(id).innerHTML = xmlhttp.responseText;
        }else if (xmlhttp.readyState==0 || xmlhttp.readyState==1 || xmlhttp.readyState==2 || xmlhttp.readyState==3) {
					document.getElementById(id).innerHTML = load;
			} else {
					document.getElementById(id).innerHTML = note;
			}
    }
    xmlhttp.send(data);
}


function Load_Pages(page, id, loading) {
    var xmlhttp=false;

    if(!xmlhttp) { 
		if (window.XMLHttpRequest)
			xmlhttp=new XMLHttpRequest(); 
		else if (window.ActiveXObject)
			xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');	
	}
		xmlhttp.open('GET', page+'&r='+(new Date().getTime()), true);
    xmlhttp.onreadystatechange = function() {
        if(xmlhttp.readyState==4 && xmlhttp.status == 200) {
					document.getElementById(id).innerHTML = xmlhttp.responseText;
					document.body.style.cursor = 'default';
					//document.body.style.opacity = '1';
					document.getElementById('loading').style.display = 'none';
        }else if (xmlhttp.readyState==0 || xmlhttp.readyState==1 || xmlhttp.readyState==2 || xmlhttp.readyState==3) {
					document.body.style.cursor = 'wait';
					//document.body.style.opacity = '0.6';
					//document.getElementById(id).innerHTML = loading;
					document.getElementById('loading').style.display = 'block';
			} else {
					document.body.style.cursor = 'default';
					//document.body.style.opacity = '1';
					document.getElementById('loading').style.display = 'none';
					document.getElementById(id).innerHTML = note;
			}
    }
    xmlhttp.send(null);
}

function Loader(page, id) {
    var xmlhttp=false;

    if(!xmlhttp) { 
		if (window.XMLHttpRequest)
			xmlhttp=new XMLHttpRequest(); 
		else if (window.ActiveXObject)
			xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');	
	}
		xmlhttp.open('GET', page, true);
    xmlhttp.onreadystatechange = function() {
        if(xmlhttp.readyState==4 && xmlhttp.status == 200) {
					document.getElementById(id).innerHTML = xmlhttp.responseText;
        }else if (xmlhttp.readyState==0 || xmlhttp.readyState==1 || xmlhttp.readyState==2 || xmlhttp.readyState==3) {
					document.getElementById(id).innerHTML = MainLoading;
			} else {
					document.getElementById(id).innerHTML = note;
			}
    }
    xmlhttp.send(null);
}


function shownl(page, id) {
    var xmlhttp=false;

    if(!xmlhttp) { 
		if (window.XMLHttpRequest)
			xmlhttp=new XMLHttpRequest(); 
		else if (window.ActiveXObject)
			xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');	
	}
		xmlhttp.open('GET', page, true);
    xmlhttp.onreadystatechange = function() {
        if(xmlhttp.readyState==4 && xmlhttp.status == 200) {
					document.getElementById(id).innerHTML = xmlhttp.responseText;
        }
    }
    xmlhttp.send(null);
}


function setCookie(sName, sValue, oExpires, sPath, sDomain, bSecure) {
	var sCookie = sName + "=" + encodeURIComponent(sValue);
	if (oExpires) {
		sCookie += "; expires=" + oExpires.toGMTString();
	}
	if (sPath) {
		sCookie += "; path=" + sPath;
	}
	if (sDomain) {
		sCookie += "; domain=" + sDomain;
	}
	if (bSecure) {
		sCookie += "; secure";
	}
	if (document.cookie = sCookie) {
		document.getElementById('rewe').innerHTML = '(&#1575;&#1606;&#1580;&#1575;&#1605; &#1588;&#1583;)';	}
		else {
			document.getElementById('rewe').innerHTML = '(&#1575;&#1606;&#1580;&#1575;&#1605; &#1606;&#1588;&#1583;)';
		}
	}
	
	function getCookie(sName) {
		var sRE = "(?:; )?" + sName + "=([^;]*);?";
		var oRE = new RegExp(sRE);
		if (oRE.test(document.cookie)) {
		return decodeURIComponent(RegExp["$1"]);
		} else {
		return null;
	}
}