var fullURL = parent.document.URL // complete url address
//var reg = new RegExp("\/test\/*\/[0-9]+.htm"); // test server
var reg = new RegExp("\/jobs\/.*\/[0-9]+.htm"); // live server

function parameter(queryString){
	var strAllParam;
	var strParam;
	var strValue;
	
	if(fullURL.indexOf("?") != -1){
		strAllParam = fullURL.split("?");
		strParam = strAllParam[1].split("&");
		for(i in strParam){
			strValue = strParam[i].split("=");
			if(strValue[0] == queryString){
				return strValue[1];
			}
		}
	}
	return "";
}

function jsWin(url,width,height)
{
	if(width != 0)
		thewidth = width;
	else
		thewidth = 500;
	if(height != 0)
		theheight = height;
	else
		theheight = 250;

	if(url == "")
		url = "http://www.jobstreet.com.sg/utility/firm_only.htm";

	window.open(url,"","location=no,status=no,resizable=yes,toolbar=no,scrollbars=yes,width="+thewidth+",height="+theheight);
	return false;
}

function opwin1(url,h,w)
{
   theHeight = screen.availHeight * h;
   window.open(url, "newwindow", "toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=top,status=no,width="+w+",height="+theHeight+",ScreenX=0,ScreenY=0,Top=0,Left=0");
}

if(fullURL.match(reg)){
	
	var strVal = parameter("fr").toUpperCase();

	if(strVal == "J" || strVal == "L" || strVal == "M" || strVal == "C" || strVal == "R" || strVal == "T" || strVal == "A" || strVal == "E"){
		var objInput = document.createElement('INPUT');
		objInput.type = "hidden";
		objInput.name = "fr";
		objInput.value = strVal;
	
		window.onload = function addObject(){
    		if(document.forms[0] != null){
               	document.forms[0].appendChild(objInput);
    		}
		}
	}
}


function setIframeHeight(iFrame){ 
    // get fs from cookie, but if cookie unavailable, will default height to 320
    var intFrameHeight = document.cookie.match('fs=(.*?)(;|$|&)');
	if (intFrameHeight == null)
		intFrameHeight = 320;
	else
		intFrameHeight = (unescape (intFrameHeight[1]));
		
	var currentfr=document.getElementById(iFrame);
	if (currentfr)
	    currentfr.height = intFrameHeight;
}	
