﻿
function getCookie(NameOfCookie){
    if (document.cookie.length > 0) {              
    	begin = document.cookie.indexOf(NameOfCookie+"=");       
	    if (begin != -1) {           
    	  	begin += NameOfCookie.length+1;       
      		end = document.cookie.indexOf(";", begin);
      		if (end == -1) end = document.cookie.length;
        		return unescape(document.cookie.substring(begin, end));
    		} 
  		}
  	return "main.php";
}

function setCookie(NameOfCookie, value, expiredays) {
	var ExpireDate = new Date ();
	ExpireDate.setTime(ExpireDate.getTime() + (3000));
	document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()) + "; path=/";
}

function delCookie (name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path == null) ? "" : "; path=" + path) +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function DoTheCookieStuff(){
		var url=window.location;
		setCookie('url',url,20);
		if(window.name != "content"){
			window.location= "index.php";
		}
}

function DoTheCookie(){
		var url=window.location;
		setCookie('url',url,20);
		if(window.name != "content"){
			window.location= "index.php";
		}
}

function replace(newst, subst, rplString) {
  var temp = "";
  var scope = subst.length;
  var pos = 0;
  while (rplString.indexOf(subst, rplString) > -1) {
    pos = rplString.indexOf(subst,rplString);
    temp += rplString.substring(0,pos)+newst;
    rplString = rplString.substring(pos+scope,rplString.length);
  }
  temp += rplString.substring(0,rplString.length);
  return temp;
}

	//var new_url = replace('','http:\/\/'+location.host+'/english/',getCookie('url'));
	function openWin( windowURL, windowName, windowFeatures ) { 
		return window.open( windowURL, windowName, windowFeatures ) ; 
	} 

