<!--
// ----------------------------------------
// @ remove space
// ----------------------------------------	
function trim(Str){
 return Str.replace (/ +/g," ").replace (/^ +/,"").replace (/ +$/,"");   
}

// ----------------------------------------
// @ new window open
// ----------------------------------------	
function Openwin(loc,wid,he,scr,res){
	LeftPosition = (screen.width) ? (screen.width-wid)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-he)/2 : 0;
	window.open(loc,'newwin', 'top='+TopPosition + ',left='+LeftPosition + ',width='+wid + ',height='+he + ',scrollbars='+scr + ',resizable='+res+ ',toolbar=no').focus();
}
// ----------------------------------------
// @ go to URL
// ----------------------------------------	
function goToUrl (loc) {
	location.href = loc;
}	

// ----------------------------------------
// @ check all checkbox
// ----------------------------------------	
function selAll(){				
	var field=document.listform.dataid;	
	
	if (field != undefined) {
		if (field.length == undefined) {
			field.checked=true;	
		}	else {				
			for (j=0; j<field.length; j++)
				field[j].checked=true;									
		}	
	}
	
	cf = 'true';		
}	

// ----------------------------------------
// @ release check all checkbox
// ----------------------------------------				
function deSelAll() {
	var field=document.listform.dataid;
	
	if (field != undefined) {
		if (field.length == undefined) {
			field.checked=false;	
		}
		else {
		 	for (j=0; j<field.length; j++)
				field[j].checked=false;				
		}				
	}
	  	
	cf = 'false';		  	
}

// ----------------------------------------
// @ return checked
// ----------------------------------------				
function checkboxChk(field){
				
	var ischeck = false;

	if (field != undefined) {
		if (field.length == undefined) {
			if (field.checked) ischeck=true;	
		}else {				
			for (j=0; j<field.length; j++) {
				if (field[j].checked) {
					ischeck=true;										
					break;
				}
			}
		}	
	}
	return ischeck;
}

// ----------------------------------------
// @ return div object
// ----------------------------------------				
function getObject(objectID) {
	if (document.getElementById && document.getElementById(objectID)) {
		return document.getElementById(objectID)
	} else if (document.all && document.all(objectID)) {		// IE4
		return document.all(objectID);
	} else if (document.layers && document.layers[objectID]) {		//NS4
		return document.layers[objectID];
	} else {
		return false;
	}
}

// ----------------------------------------
// @ make search url
// ----------------------------------------				
function getSearchQS() {
	var frm = document.frmBidSrch;	
	var qs = "stk";	
	
	var kw = trim (frm.kw.value);
	if (kw != "") {
		kw = kw.replace(/\./g, "!");
		kw = kw.replace(/\//g, "$");
		kw = kw.replace(/-/g, "|");
		kw = "-" + kw.replace(/[ ]+/g, "-");		
		kw = escape (kw);	
		qs += ".kw" + kw;
	}
	
	var ar = trim (frm.ar.value);
	if (ar != "notselected") {
		if (ar.length == 1) {
			qs += ".ac" + ar;
		} 
		else if (ar.length == 3) {
			qs += ".ar" + ar;
		} 
	}
	
	if (frm.so.checked) {
		qs += ".so1";
	}
	return qs;
}


// ----------------------------------------
// @ cookie setting
// ----------------------------------------				
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())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");	
}

// ----------------------------------------
// @ get cookie
// ----------------------------------------				
function getCookieVal(offset) {
	var endstr = document.cookie.indexOf(";",offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

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 deleteCookie(name) {	
	var argv = deleteCookie.arguments;  
	var argc = deleteCookie.arguments.length;  

	var path = (argc > 1) ? argv[1] : null;  
	
	document.cookie = name + "=; expires=" + (new Date()).toGMTString() + 			
	((path == null) ? "" : ("; path=" + path));
}

// ----------------------------------------
// @ call web page
// ----------------------------------------			
function loadHTMLDoc(url)
{
  //alert(url);
  req = false;
  if(window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
        } catch(e) {
      req = false;
        }
  }
  else if(window.ActiveXObject)
  {
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
    	try {
      	req = new ActiveXObject("Microsoft.XMLHTTP");
    	} catch(e) {
      	req = false;
    	}
  	}
  }

  if(req) {    
    req.open("GET", url, true);
    req.setRequestHeader('Cache-Control','0');
    //alert(req.getRequestHeader('Cache-Control'));
    req.send();
  }
}


// ----------------------------------------
// @ entity checking
// ----------------------------------------		
var numb = '0123456789';
var lwr = 'abcdefghijklmnopqrstuvwxyz';
var upr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
 
function isValid(parm,val) {
  if (parm == "") return false;
  for (i=0; i<parm.length; i++) {
    if (val.indexOf(parm.charAt(i),0) == -1) return false;
  }
  return true;
}
 
function isNum(parm) {return isValid(parm,numb);}
function isLower(parm) {return isValid(parm,lwr);}
function isUpper(parm) {return isValid(parm,upr);}
function isAlpha(parm) {return isValid(parm,lwr+upr);}
function isAlphanum(parm) {return isValid(parm,lwr+upr+numb);}

// -------------------------------------------------------
// @ show more / show less
// --------------------------------------------------------		
function showmore(divid) {	
	if (!document.getElementById) return false;
	var div = document.getElementById(divid); 
	var div_more = document.getElementById(divid+"-more"); 	
	if (div) {
		div.style.display = "none";
		div_more.style.display = "block";
	}		
}
function showMoreCountry() {
	if (!document.getElementById) return false;
	var div = document.getElementById("filter-allcountry"); 	
	div.style.display = "block";
	var div_more = document.getElementById("filter-country-more");	
	if (div_more && div_more.childNodes.length > 0) {
		div_more.className = "filter-showless";
		div_more.childNodes[0].setAttribute("href","javascript:showLessCountry()")				
		div_more.childNodes[0].childNodes[0].nodeValue = "show less";	
	}
}
function showLessCountry() {	
	if (!document.getElementById) return false;
	var div = document.getElementById("filter-allcountry");
	div.style.display = "none";
	// change show less
	var div_more = document.getElementById("filter-country-more");
	if (div_more && div_more.childNodes.length > 0) {
		div_more.className = "filter-showmore";
		div_more.childNodes[0].setAttribute("href","javascript:showMoreCountry()")				
		div_more.childNodes[0].childNodes[0].nodeValue = "show more";		
	}
}
function changeState() {
	var idx = document.frmJoin.fcountry.selectedIndex;
	var flag_disp = 0;
	var array_index = 0;
	var thisStateObj = null;	
	if (idx > 0) {		
		var ncode = document.frmJoin.fcountry.options[document.frmJoin.fcountry.selectedIndex].value.substring(0,3);		
		for (var j in states) {			
			if (ncode == j) {
				thisStateObj = states[j];
				flag_disp =1
			}
		}		
	}
	
	var obj1 = getObject("section-state");
	var obj2 = getObject("section-other");
	
	if (flag_disp) {						
		obj1.style.display = "block";
		obj2.style.display = "none";
		document.frmJoin.fstate.options.length = 1;
		for (var i=0; i < thisStateObj.length; i++) {			
			document.frmJoin.fstate.options[i+1] = new Option(thisStateObj[i].substring(9,thisStateObj[i].length),thisStateObj[i].substring(0,8));
		}
	} else {
		obj1.style.display = "none";
		obj2.style.display = "block";
	}
}
function checkAll() {
	var frm = document.frmJoinCountry;
	for (i=1;i<frm.fcontinent.length;i++)
		frm.fcontinent[i].checked = false;	
	for (i=0;i<frm.fregion.length;i++)
		frm.fregion[i].checked = false;	
}
function checkItem(value) {		
	var frm = document.frmJoinCountry;
	frm.fcontinent[0].checked = false;
	start_block = false;
	end_block = false;
	for (i=0;i<frm.fregion.length;i++) {			
		if (frm.fregion[i].value.substring(0,1) == value) {
			if (!start_block) start_block = true;
			frm.fregion[i].checked = false;
		} else {
			if (start_block) end_block = true;
		}			
		if (end_block) break;
	}
}
function checkItem2(no) {	
	var frm = document.frmJoinCountry;
	frm.fregion[0].checked = false;
	var idx = null;
	for (i=1;i<=frm.fcontinent.length;i++) {
		if (frm.fcontinent[i].value == no) {
			idx = i;
			break;
		}
	}
	if (idx != null) frm.fcontinent[idx].checked = false;
}
function show_country(divNo) {
	if (!document.getElementById) return false;
	var div = document.getElementById("fld-continent"+divNo);		
	div.style.display = "block";
	var linkObj = document.getElementById("linkShowCountry-"+divNo);
	linkObj.setAttribute("href","javascript:close_country("+divNo+")");
	linkObj.setAttribute("title","Click to hide countries");
	linkObj.childNodes[0].setAttribute("src","/images/icon_minus.gif");
	linkObj.childNodes[0].setAttribute("alt","Click to hide countries");
	
}
function close_country(divNo) {
	if (!document.getElementById) return false;
	var div = document.getElementById("fld-continent"+divNo);		
	div.style.display = "none";
	var linkObj = document.getElementById("linkShowCountry-"+divNo);
	linkObj.setAttribute("href","javascript:show_country("+divNo+")");
	linkObj.setAttribute("title","Click to display countries");
	linkObj.childNodes[0].setAttribute("src","/images/icon_plus.gif");
	linkObj.childNodes[0].setAttribute("alt","Click to display countries");		
}
function clearDfEmail() {
	var df_value = "Enter Your Email";
	var fld = document.frmJoinMail.femail;		
	if (fld.value == df_value) {
		fld.value = "";		
	}
	fld.style.textAlign = "left";
	fld.style.fontStyle = "normal";	
}
//-->	