

var expDays = 1; // number of days the cookie should last



var path = "/";



var domain ;

var locapath = document.location.href



if (locapath.toString().search('/preview/')!= -1){

	var page  = "/preview";

}else{

	var page  = "";

}



if (locapath.toString().search('/textonly/')!= -1){

	 page += "/textonly/chs/disclaimer/statment.html";

}else{

	 page += "/chs/disclaimer/statment.html";

}





org_path_start = locapath.indexOf("://") + 3;

org_path_end = locapath.length;

domain = locapath.substring(org_path_start, org_path_end);

if (domain.toString().search('/')!= -1){

org_path_start = 0;

org_path_end = domain.indexOf("/");

domain = domain.substring(org_path_start, org_path_end);

}





function GetCookie (name) {  

var arg = name + "=";  

var alen = arg.length;  

var clen = document.cookie.length;  

var i = 0;  

while (i < clen) {    

var j = i + alen;    

if (document.cookie.substring(i, j) == arg)      

return getCookieVal (j);    

i = document.cookie.indexOf(" ", i) + 1;    

if (i == 0) break;   

}  

return null;

}

function SetCookie (name, value) {  

var argv = SetCookie.arguments;  

var argc = SetCookie.arguments.length;  

var expires = (argc > 2) ? argv[2] : null;  

//var path = (argc > 3) ? argv[3] : null;  

//var domain = (argc > 4) ? argv[4] : null;  



var secure = (argc > 5) ? argv[5] : false;  

document.cookie = name + "=" + escape (value) + 

//((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 

//((expires == null) ? "" : ("; expires=")) + 

((path == null) ? "" : ("; path=" + path)) +  

((domain == null) ? "" : ("; domain=" + domain)) +    

((secure == true) ? "; secure" : "");

}

function DeleteCookie (name) {  

var exp = new Date();  

exp.setTime (exp.getTime() - 1);  

var cval = GetCookie (name);  

document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();

}

var exp = new Date(); 

exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function amt(){

var count = GetCookie('sccount')

if(count == null) {

SetCookie('count','1')

return 1

}

else {

var newcount = parseInt(count) + 1;

DeleteCookie('sccount')

SetCookie('sccount',newcount,exp)

return count

   }

}

function getCookieVal(offset) {

var endstr = document.cookie.indexOf (";", offset);

if (endstr == -1)

endstr = document.cookie.length;

return unescape(document.cookie.substring(offset, endstr));

}



function checkCount() {

var sccount = GetCookie('sccount');

if (sccount == null) {



SetCookie('orgiurl',document.location.href, exp);



window.location.href=page;

}

else {

//count++;

//SetCookie('count', count, exp);

   }

}



//if ((locapath.toString().search('/sc_chi/')!= -1)||(locapath.toString().search('cmain.html')!= -1))   {

//	checkCount();

//}







//Finish Check SC statment









var dept = "/";

var domain = "";

var scserver = "http"+"://";

var locapath = document.location.href

//var locapath = "http://www.sar-expertcom.gov.hk/textonly/emain.html";









var atlang,domname,sitepath,atgb,atindex,org_part;

	sc_path = "chs/";

	sctxt_path = "textonly/chs/";

	tc_path = "chs/";

	tctxt_path = "textonly/chs/";

	en_path = "eng/";

	entxt_path = "textonly/eng/";

	atgb = false;

	atindex = false;



if (locapath.toString().search('/chs/')!= -1){

	atgb = true;

	org_path_start = locapath.indexOf("/chs/") +5;

	org_path_end = locapath.length;

	sitepath = locapath.substring(org_path_start, org_path_end);

}else{

	atgb = false;

	sitepath = locapath.substring(7,locapath.length);

}



if (locapath.toString().search('/textonly/eng/')!= -1){

	atlang = "entxt";

	org_part = entxt_path;

}else

if (locapath.toString().search('/textonly/tc_chi/')!= -1){

	atlang = "tctxt";

	org_part = tctxt_path;

}else

if (locapath.toString().search('/textonly/chs/')!= -1){

	atlang = "sctxt";

	org_part = sctxt_path;

}else

if (locapath.toString().search('/eng/')!= -1){

	atlang = "en";

	org_part = en_path;

}else

if (locapath.toString().search('/chs/')!= -1){

	atlang = "sc";

	org_part = sc_path;

}else

if (locapath.toString().search('/textonly/emain.html')!= -1){

	atlang = "txteindex";

	org_part = "textonly/emain.html";

	atindex = true;

}else

if (locapath.toString().search('emain.html')!= -1){

	atlang = "eindex";

	org_part = "emain.html";

	atindex = true;

}else

if (locapath.toString().search('/textonly/cmain.html')!= -1){

	atlang = "txtcindex";

	org_part = "textonly/cmain.html";

	atindex = true;

}else

if (locapath.toString().search('cmain.html')!= -1){

	atlang = "cindex";

	org_part = "cmain.html";

	atindex = true;

}else

if (locapath.toString().search('/textonly/smain.html')!= -1){

	atlang = "txtsindex";

	org_part = "textonly/smain.html";

	atindex = true;

}else

if (locapath.toString().search('smain.html')!= -1){

	atlang = "sindex";

	org_part = "smain.html";

	atindex = true;

}



//domain = sitepath.substring(0, sitepath.indexOf("/"));

domain = "202.57.255.178";

subdir = "/preview";



function chglang(lang) {
	lh = location.href;
	switch(lang) {
		case 'entxt':
			replace1 = "/beStrong/textonly/emain.html";
			replace2 = "/beStrong/textonly/eng/";
			break;
		case 'tctxt':
			replace1 = "/beStrong/textonly/cmain.html";
			replace2 = "/beStrong/textonly/tc_chi/";
			break;
		case 'sctxt':
			replace1 = "/beStrong/textonly/smain.html";
			replace2 = "/beStrong/textonly/chs/";
			break;
		case 'en':
			replace1 = "/beStrong/emain.html";
			replace2 = "/beStrong/eng/";
			break;
		case 'tc':
			replace1 = "/beStrong/cmain.html";
			replace2 = "/beStrong/tc_chi/";
			break;
		case 'sc':
			replace1 = "/beStrong/smain.html";
			replace2 = "/beStrong/chs/";
			break;
	}
	lh = lh.replace("/beStrong/textonly/emain.html", replace1);
	lh = lh.replace("/beStrong/textonly/cmain.html", replace1);
	lh = lh.replace("/beStrong/textonly/smain.html", replace1);
	lh = lh.replace("/beStrong/emain.html", replace1);
	lh = lh.replace("/beStrong/cmain.html", replace1);
	lh = lh.replace("/beStrong/smain.html", replace1);
	lh = lh.replace("/beStrong/textonly/eng/", replace2);
	lh = lh.replace("/beStrong/textonly/tc_chi/", replace2);
	lh = lh.replace("/beStrong/textonly/chs/", replace2);
	lh = lh.replace("/beStrong/eng/", replace2);
	lh = lh.replace("/beStrong/tc_chi/", replace2);
	lh = lh.replace("/beStrong/chs/", replace2);

	location.href = lh;
}
/*
function chglang(lang){



	switch(lang){

		case 'entxt': 

			des_part = entxt_path;

			des_ind_part = "textonly/emain.html";

			base_path = "http://";

			break;

		case 'tctxt':

			des_part = tctxt_path;

			des_ind_part = "textonly/cmain.html";

			base_path = "http://";

			break;

		case 'sctxt':

			des_part = sctxt_path;

			des_ind_part = "textonly/smain.html";

			base_path = "http://";
			break;

		case 'en':

			des_part = en_path;

			des_ind_part = "emain.html";

			base_path = "http://";

			break;

		case 'tc':

			des_part = tc_path;

			des_ind_part = "cmain.html";

			base_path = "http://";

			break;

		case 'sc':

			des_part = sc_path;

			des_ind_part = "smain.html";

			base_path = "http://";
			break;

	}



	if (atindex == true){

		tail = sitepath.replace(org_part, des_ind_part);

	}else{

		tail = sitepath.replace(org_part, des_part);

	}



//alert(base_path+tail)

	//if(lang == 'sctxt' || lang == 'sc'){

	//	window.location =  "#";

	//} else {

		window.location =  base_path+tail;

	//}



}



*/
function tellafriend( lang )

{

  if (lang == 'eng')

  {

     window.location = subdir + '../tell/tell.asp?base=http%3A//'+ domain + subdir + '../tell/&url=' + escape(window.location);

  }else if (lang == 'chi')

  {

     window.location = subdir + '/chs/tell/tell.asp?base=http%3A//'+ domain + subdir + '/chs/tell/&url=' + escape(window.location);

  }else if (lang == 'schi')

  {

     window.location = subdir + '/sc_chi/tell/tell.asp?base=http%3A//'+ domain + subdir + '/sc_chi/tell/&url=' + escape(window.location);

  }else if (lang == 'eng_txt')  

  {

     window.location = subdir + '/textonly../tell/tell.asp?base=http%3A//'+ domain + subdir + '/textonly../tell/&url=' + escape(window.location);

  }else if (lang == 'chi_txt')

  {

     window.location = subdir + '/textonly/tc_chi/tell/tell.asp?base=http%3A//'+ domain + subdir + '/textonly/tc_chi/tell/&url=' + escape(window.location);

  }else if (lang == 'schi_txt')

  {

     window.location = subdir + '/textonly/sc_chi/tell/tell.asp?base=http%3A//'+ domain + subdir + '/textonly/sc_chi/tell/&url=' + escape(window.location);

  }

  //window.location = '../tell/tell.html?url=' + escape(window.location);

}



function splitString (stringToSplit,separator) {

 var arrayOfStrings = stringToSplit.split(separator);

 return arrayOfStrings[1];

}