// JavaScript Document
<!--
var gShow; //variable holding the id where feedback will be sent to.
var mailUrl = "common/check_mail.php?val=";//url is the page which will be processing all of the information.  it is important to make sure validationtype is ajax
var ICUrl = "common/check_ic.php?val=";//url is the page which will be processing all of the information.  it is important to make sure validationtype is ajax
var ICVoterUrl = "common/check_voter_ic.php?val=";
var ScreenUrl = "common/check_screenname.php?val="; //check screenname;
var loginUrl = "common/check.php?val=";//url is the page which will be processing all of the information.  it is important to make sure validationtype is ajax
var listingURL = "common/listing.php?val=";//url is the page which will be processing all of the information.  it is important to make sure validationtype is ajax
var SendVoteURL = "common/send_email.php?val=";//url is the page which will be processing all of the information.  it is important to make sure validationtype is ajax
var previewURL = "common/preview.php?val="
var editDesignURL = "common/edit_design.php?var="
var AlllistingURL = "common/alllisting.php";
var pageListingURL = "common/pagelisting.php";
var pageListingURL2 = "common/pagelisting2.php?page=";
var getGalleryPagesURL = "common/getpages.php";

var voteURL = "common/voteload.php?var=";
var getNumvoteURL = "common/votenum.php?var=";
var tshirtUrl = "common/loadtshirt.php";
var gErrors = 0; //number of errors is set to none to begin with
var http = getHTTPObject();//don't worry about this
var emailStore;
var ICStore;
var global_select_tr = "";
var global_nomination = "";
var global_Institution = "";
var errorEmailMessage = "Invalid email address.";




var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i



function loadVoteMe(obj){
			gShow = "votePanel";
			http.open("GET", voteURL + (obj), true);
			http.onreadystatechange = handleHttpResponse; 
			http.send(null);
}

function MouseOverHighlight(obj,actionPass){
		if (actionPass == 1){
				obj.style.border="1px solid #999999";
		} else {
				obj.style.border="1px solid #333333";
		}
}

function VoteThis(objValue){
	//alert(objValue);
	location.href="vote.php?select="+objValue;
}

function EditThis(objInput){
			gShow = "editPanel";
			http.open("GET", editDesignURL + (objInput), true);
			http.onreadystatechange = handleHttpResponse; 
			http.send(null);
}

function sendMail(objInput,returnInnerHTMLId){
	sVal = objInput.elements[0].value;
	if (sVal.length!=0){
					gShow = "emailArea";
					http.open("GET", SendVoteURL + (sVal), true);
					http.onreadystatechange = handleHttpResponse; 
					http.send(null);
					return false;

	} else {
		document.getElementById(returnInnerHTMLId).innerHTML = "<span style='color:#FFCC00;'>Please enter email address(es).</span>";
		document.getElementById(returnInnerHTMLId).focus();
		return false;
	}
	
}


function getListing(){
			gShow = "listing";
			sVal="listing";
			http.open("GET", listingURL + (sVal), true);
			http.onreadystatechange = handleHttpResponse; 
			http.send(null);
}

function getAllListing(){
			gShow = "listing";
			http.open("GET", AlllistingURL, true);
			http.onreadystatechange = handleHttpResponse; 
			http.send(null);
}

function getPageListing(){
			gShow = "listing";
			http.open("GET", pageListingURL, true);
			http.onreadystatechange = handleHttpResponse; 
			http.send(null);
}

function getPageListing2(sVal){
			//document.getElementById('loadinger').style.visibility="visible";
			
			gShow = "listing";
			document.getElementById(gShow).innerHTML = "<div style='color:#FFFFFF;width:100%; height:100%; text-align:center;padding-top:50px;'><img src='../images/ajax_loader.gif' width='24' height='24' /></span>";
			http.open("GET", pageListingURL2+ (sVal), true);
			http.onreadystatechange = handleHttpResponse; 
			http.send(null);
}
function checkMail(obj) {
		document.getElementById('loading_email').style.visibility="visible";
		document.getElementById('email_man_email').style.display="none";
		var at="@";
		var dot=".";
		var str = obj.value
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		var emailId = obj.id;
		var emailAlert = emailId.split("_");
		
		//alert_email
		if ((obj.value!=null)||(obj.value!="")){
				if (str.indexOf(at)==-1){
					document.getElementById("alert_"+emailAlert[2]).innerHTML = errorEmailMessage;
		document.getElementById('loading_email').style.visibility="hidden";
		document.getElementById('email_man_email').style.display="block";
					document.getElementById(emailId).value = "";
					document.getElementById(emailId).focus();
				   return false;
				}
				if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
					document.getElementById("alert_"+emailAlert[2]).innerHTML = errorEmailMessage;
		document.getElementById('loading_email').style.visibility="hidden";
		document.getElementById('email_man_email').style.display="block";
					document.getElementById(emailId).value = "";
					document.getElementById(emailId).focus();
				   return false;
				}
				if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
					document.getElementById("alert_"+emailAlert[2]).innerHTML = errorEmailMessage;
		document.getElementById('loading_email').style.visibility="hidden";
		document.getElementById('email_man_email').style.display="block";
					document.getElementById(emailId).value = "";
					document.getElementById(emailId).focus();
					return false;
				}
				 if (str.indexOf(at,(lat+1))!=-1){
					document.getElementById("alert_"+emailAlert[2]).innerHTML = errorEmailMessage;
		document.getElementById('loading_email').style.visibility="hidden";
		document.getElementById('email_man_email').style.display="block";
					document.getElementById(emailId).value = "";
					document.getElementById(emailId).focus();
					return false;
				 }
				 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
					document.getElementById("alert_"+emailAlert[2]).innerHTML = errorEmailMessage;
		document.getElementById('loading_email').style.visibility="hidden";
		document.getElementById('email_man_email').style.display="block";
					document.getElementById(emailId).value = "";
					document.getElementById(emailId).focus();
					return false;
				 }
				 if (str.indexOf(dot,(lat+2))==-1){
					document.getElementById("alert_"+emailAlert[2]).innerHTML = errorEmailMessage;
		document.getElementById('loading_email').style.visibility="hidden";
		document.getElementById('email_man_email').style.display="block";
					document.getElementById(emailId).value = "";
					document.getElementById(emailId).focus();
					return false;
				 }
				 if (str.indexOf(" ")!=-1){
					document.getElementById("alert_"+emailAlert[2]).innerHTML = errorEmailMessage;
		document.getElementById('loading_email').style.visibility="hidden";
		document.getElementById('email_man_email').style.display="block";
					document.getElementById(emailId).value = "";
					document.getElementById(emailId).focus();
					return false;
				 }
			subCheckMail(str);
		}		
}

	
	
function subCheckMail(objInput){
			sVal = objInput;
		if (sVal.length>0){
			http.open("GET", mailUrl + (sVal), true);
			http.onreadystatechange = handleHttpResponse; 
			http.send(null);
		}
}



function formatNRIC(objValue) {
		tmpStr = objValue.toUpperCase();
		tmpStrTrim = tmpStr.replace(/^\s+|\s+$/g,"");
		 for (var c = 0; c < tmpStrTrim.length; c++){
			 objValue = tmpStrTrim.split(' ').join('');
		 }
		return objValue;
}






function checkScreen(objInput){
	if ((objInput.value!=null)||(objInput.value!="")){
		document.getElementById('loading_screen').style.visibility="visible";
		document.getElementById('norm_man_screenname').style.display="none";
		document.getElementById('screen_target').src=ScreenUrl+objInput.value;
	}
}
function checkScreenReturn(obj){
		if (obj==1){
				document.getElementById('alert_screenname').innerHTML = "";
				document.getElementById('loading_screen').style.visibility="hidden";
				document.getElementById('norm_man_screenname').style.display="block";
		} else {
				document.getElementById('loading_screen').style.visibility="hidden";
				document.getElementById('norm_man_screenname').style.display="block";
				document.getElementById('norm_man_screenname').value = "";
				document.getElementById('alert_screenname').innerHTML = "Screen name has been taken. Please choose another.";
		}
}

var ICReturn = "";

function checkIC(objInput){
	var sTrim="";
	if ((objInput.value!=null)||(objInput.value!="")){
		tmpStr = objInput.value.toUpperCase();
		tmpStrTrim = tmpStr.replace(/^\s+|\s+$/g,"");
		 for (var c = 0; c < tmpStrTrim.length; c++){
			sTrim = tmpStrTrim.split(' ').join('');
		 }
		// alert(sTrim);
		ICReturn = sTrim
		objInput.value = ICReturn;
		//document.getElementById('loading_ic').style.visibility="visible";
		//objInput.style.display = "none";
		document.getElementById('votesign_target').src=ICUrl+ICReturn;
	}
}


function format_IC(objValue) {
	var sTrim="";
	if (objValue.value.length>0){
		tmpStr = objValue.value.toUpperCase();
		tmpStrTrim = tmpStr.replace(/^\s+|\s+$/g,"");
		 for (var c = 0; c < tmpStrTrim.length; c++){
			sTrim = tmpStrTrim.split(' ').join('');
		 }
		objValue.value = sTrim;
	}
}


function checkVoterIC(objInput){
	var sTrim="";
	if (objInput.value.length>0){
		tmpStr = objInput.value.toUpperCase();
		tmpStrTrim = tmpStr.replace(/^\s+|\s+$/g,"");
		 for (var c = 0; c < tmpStrTrim.length; c++){
			sTrim = tmpStrTrim.split(' ').join('');
		 }
		// alert(sTrim);
		ICReturn = sTrim
		objInput.value = ICReturn;
		document.getElementById('votesign_target').src=ICVoterUrl+ICReturn;
	}
}

function checkICReturn2(obj){
		if (obj==0){
				document.getElementById('norm_man_nric2').value = "";
				document.getElementById('alert_nric2').innerHTML = "<br>You had already sign up. Please click <a href=\"index.php?login=1\" style=\"color:#FFFFFF\">here</a> to login";
		}
}


function checkICReturn(obj){
		if (obj==1){
				document.getElementById('alert_nric').innerHTML = "";
				document.getElementById('loading_ic').style.visibility="hidden";
				document.getElementById('norm_man_nric').style.display="block";
				document.getElementById('norm_man_nric').value=ICReturn;
		} else {
				document.getElementById('loading_ic').style.visibility="hidden";
				document.getElementById('norm_man_nric').style.display="block";
				document.getElementById('norm_man_nric2').value = "";
				document.getElementById('alert_nric2').innerHTML = "<br>You had already sign up. Please click <a href=\"index.php?login=1\" style=\"color:#FFFFFF\">here</a> to login";
		}
}

function checkSign(objInput){
		sVal = objInput;
		document.getElementById('screen_target').src=loginUrl+sVal;
}
function checkSignReturn(passAction,passName,passExpire,passId){
	
					if (passAction==0){
						messageReturn = "Sign in not successful. Please try again.";
						goNow = 0;
					} else if (passAction==1){
						messageReturn = "Sign in successful. Re-directing you now...";
						goNow = 1;
					} else if (passAction==2){
						messageReturn = "You have not verify for registration yet. Please check your mail";
						goNow =0;

					}
					
					document.getElementById('loginReturn').innerHTML = "";
					document.getElementById('loginReturn').innerHTML = messageReturn;
					document.getElementById('Eff_lock').value=passName;
					document.getElementById('Eff_locktime').value=passExpire;
					document.getElementById('Eff_Id').value=passId;
					if (goNow ==1){
					document.getElementById('Eff_frm').submit();
					}
}


function ajaxCheck(obj){
		var getFields="";
		var getValue="";
		var strFieldCount = 0;
		 for (var c = 0; c < obj.elements.length; c++){
			// alert(obj.elements[c].value);
			  var name_array = obj.elements[c].id.split("_");
			if ((name_array[1]=="man") || (name_array[0]=="cookie")){
					 if (getValue==""){
							getValue =  obj.elements[c].value;
					 } else {
							getValue =  getValue+"|"+obj.elements[c].value;
					 }
				if (name_array[0]!="cookie"){
					if (obj.elements[c].value.length==0){
						document.getElementById("alert_"+name_array[2]).innerHTML = "<br>This is a required field";
						strFieldCount = parseFloat(strFieldCount)+1;
					}else{
						document.getElementById("alert_"+name_array[2]).innerHTML = "";
					};
				}
			};
		 };
		if (strFieldCount>0){
		 	if (strFieldCount>1){
				strLetterS = "s";
			}else{
				strLetterS ="";
			}	
			return false;
		 }else{
			checkSign(getValue);
			//alert(getValue)
			return false;
		 }
}

function Trim(str) {
  return str.replace(/^s+|s+$/g,"");
}

function handleHttpResponse() {
		if (http.readyState == 4) 
		{
		Results = http.responseText; 
		Trim(Results);
		
			if (Results=="invalidEmail"){
				document.getElementById('loading_email').style.visibility="hidden";
				document.getElementById('email_man_email').style.display="block";
				document.getElementById('email_man_email').value = "";
				document.getElementById('alert_email').innerHTML = errorEmailMessage;
			} else if (Results=="validEmail") {
				document.getElementById('alert_email').innerHTML = "";
				document.getElementById('loading_email').style.visibility="hidden";
				document.getElementById('email_man_email').style.display="block";
			} else {
				sResults = Results.split("|"); 
				if (sResults[1]){
					document.getElementById(gShow).innerHTML = "";
					document.getElementById(gShow).innerHTML = sResults[0];
					document.getElementById('Eff_lock').value=sResults[1];
					document.getElementById('Eff_locktime').value=sResults[2];
					document.getElementById('Eff_Id').value=sResults[3];
					document.getElementById('Eff_frm').submit();
				} else{
					document.getElementById(gShow).innerHTML = "";
					document.getElementById(gShow).innerHTML = Results;
				} 
			}
		}
}




function getHTTPObject() {
	var xmlhttp;
	/*@cc_on
	@if (@_jscript_version >= 5)
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try 
		{
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
		xmlhttp = false;
		}
	}
	return xmlhttp;
}


var browser     = '';
var version     = '';
var entrance    = '';
var cond        = '';
var  sniffer  = '';

if (browser == ''){
if (navigator.appName.indexOf('Microsoft') != -1)
browser = 'IE'
else if (navigator.appName.indexOf('Netscape') != -1)
browser = 'Netscape'
else browser = 'IE';
}
if (version == ''){
version= navigator.appVersion;
paren = version.indexOf('(');
whole_version = navigator.appVersion.substring(0,paren-1);
version         = parseInt(whole_version);
}
if (browser == 'IE' && version >= 4){
//document.write('<'+'link rel="stylesheet" href="ie.css" mce_href="ie.css" />');
 sniffer = 1;
}
if (browser == 'Netscape' && version >= 2.02) {
//document.write('<'+'link rel="stylesheet" href="nn.css" mce_href="nn.css" />');
 sniffer = 2;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="Function Disabled!";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

function showAndHide(show,hide){
	document.getElementById(show).style.display="block";
	document.getElementById(hide).style.display="none";
}

function goHome(where){
		location.href = where+".php";
}

function checkField(obj){
		var getFields="";
		var strFieldCount = 0;
		
		//alert(obj.elements.length);
		//return false;
		 for (var c = 0; c < obj.elements.length; c++){
			  var name_array = obj.elements[c].id.split("_");
			// alert(name_array[0]+"__"+name_array[1]+"__"+name_array[2])
			if (name_array[1]=="man"){
				if (obj.elements[c].value.length==0){
					document.getElementById("alert_"+name_array[2]).innerHTML = "<br>This is a required field";
				//	alert(name_array[2]+" - this is a required");
					strFieldCount = parseFloat(strFieldCount)+1;
				}else{
					document.getElementById("alert_"+name_array[2]).innerHTML = "";
				};
			};
		 };
		if (strFieldCount>0){
		 	if (strFieldCount>1){
				strLetterS = "s";
			}else{
				strLetterS ="";
			}	
			//location.href="#form";
			//document.getElementById('requiredText').innerHTML = "<br>You have "+strFieldCount+" required field"+strLetterS+" not completed."
			//gobalCount = strFieldCount;
			//gobalSubmission = 1;
			
		document.getElementById('signup').style.display="block";
		document.getElementById('vote_loader').style.visibility="hidden";
		document.getElementById('vote_loader').style.display="block";
			return false;
		 }else{
		   return true;
		 }

};
function changeToLower(obj) {
		tmpStr = obj.value.toLowerCase();
		tmpStrTrim = tmpStr.replace(/^\s+|\s+$/g,"");
		obj.value = tmpStrTrim;
}

function changeToUpper(obj) {
		tmpStr = obj.value.toUpperCase();
		tmpStrTrim = tmpStr.replace(/^\s+|\s+$/g,"");
		obj.value = tmpStrTrim;
}

function SendCheckValue(obj,passId){
		if (obj.checked){
			document.getElementById(passId).value=1;	
		} else {
			document.getElementById(passId).value=0;	
		}
	}
	
function logout(){
		location.href="destroy.php";
}
	
function goPage(obj){
	document.getElementById('Eff_kind').value=obj;
	//alert(document.getElementById('Eff_kind').value);
	document.getElementById('Eff_navi').submit();
}

function SetForIC(obj) {
		tmpStr = obj.value.toUpperCase();
		tmpStrTrim = tmpStr.replace(/^\s+|\s+$/g,"");
		 for (var c = 0; c < tmpStrTrim.length; c++){
			 tmpStrTrim = tmpStrTrim.split(' ').join('');
		 }
		obj.value = tmpStrTrim;
}

function matchPw(obj,otherObj){
	if((obj.value!="") && (document.getElementById(otherObj).value!="")){
		 if (obj.value!=document.getElementById(otherObj).value){
			 	alert("Your password do not match.\nPlease try again.")
				obj.value="";
				obj.focus();
			 }
		}
	}
	


function animateOpen(o1) {
	var wanted_h = 280;
	if (parseInt(o1) < parseInt(wanted_h)){
			var speed = 10;
			enlarge = parseInt(o1) + parseInt(speed);
			document.getElementById('UploadBody').style.height=enlarge+"px";
			var to = setTimeout("animateOpen("+parseInt(enlarge)+")", 10);
	} else {
			clearTimeout(to);
	}
}


function animateClose(o1) {
	var wanted_h = 1;
	if (parseInt(o1) > parseInt(wanted_h)){
			var speed = 10;
			shrink = parseInt(o1) - parseInt(speed);
			if (shrink==0){
					clearTimeout(to);
					document.getElementById('UploadBody').style.height="1px";
					document.getElementById('UploadBody').style.display="none";
			} else {
			document.getElementById('UploadBody').style.height=shrink+"px";
			var to = setTimeout("animateClose("+parseInt(shrink)+")", 10);
			}
		} else {
			document.getElementById('UploadBody').style.height="1px";
			document.getElementById('UploadBody').style.display="none";
			clearTimeout(to);
		}
}


function UploadOpen(){
		if (direction==0){
			animateOpen(1);
			direction=1;
			document.getElementById('UploadBody').style.display="block";
		} else {
			animateClose(280);
			direction=0;
		}
	}
	
function startUpload(){
	ChkValue = document.getElementById("myfile").value.length;
	 if (ChkValue==0){
		alert("Please \"Browse\" for your file to be uploaded.");
		return false;
	 }else{
		document.getElementById('f1_upload_process').style.visibility = 'visible';
		document.getElementById('f1_upload_form').style.visibility = 'hidden';
		return true;
	}
}

function saveShirt(){
		document.getElementById('f1_upload_process2').style.visibility = 'visible';
		document.getElementById('shirtContainer').style.visibility = 'hidden';
}

function DrawPreview(sVal){
			gShow = "thumbnail";
			http.open("GET", previewURL + (sVal), true);
			http.onreadystatechange = handleHttpResponse; 
			http.send(null);

}

function infoUpdated(Getdesign,tshirt){
		document.getElementById('listing2').style.display = 'none';
		document.getElementById('listing3').style.display = 'block';
	document.getElementById('mydesignArea2').style.background='url('+tshirt+')';
	document.getElementById('mydesignArea2').innerHTML = Getdesign;
	//alert(Getdesign);
	//	
		
}

function infoEdit(success){
			document.getElementById('f1_upload_process').style.visibility = 'hidden';
			document.getElementById(gShow).innerHTML="";
			getListing();
			
	}

function genThumbGo(obj,designCode){
	//alert(designCode);
		document.getElementById('f1_upload_process2').style.visibility = 'hidden';
		document.getElementById('listing').display="none";
		document.getElementById('mydesignArea').innerHTML = obj
		//document.getElementById('2designcode').value=designCode;

}

function genBigThumb(obj){
		document.getElementById('listing').style.display="none";
		document.getElementById('listing2').style.display="block";
		document.getElementById('thumbnail').innerHTML = obj
}


function stopUpload(success){
	var mySplitResult = success.split("|");
      var result = '';
      if (mySplitResult[0] == 1){
        // result = '<span class="msg"><br>The file was uploaded successfully!<br/><br/>';
		
		document.getElementById('uploadTD').style.display="none";
		document.getElementById('listing').style.display="block";
		document.getElementById('1designcode').value=mySplitResult[1];
		document.getElementById('2designcode').value=mySplitResult[1];
		
		document.getElementById('designTeeFrm').submit();
      }else if (mySplitResult[0] == 2){
         result = '<div class="msg">File existed, please rename and <a href=\'javascript:rewriteForm()\' style=\"color:#FF9900;\"><u>try</u></a> again.<\/div><br/><br/>';
      }else if (mySplitResult[0] == 3){
         result = '<div class="msg">Your design should be in JPG format, 160 X 160 pixels<br> in dimension at72 dpi and not more than 400kb in size.<br>Please <a href=\'javascript:rewriteForm()\' style=\"color:#FF9900;\"><u>try</u></a> again.<\/div><br/><br/>';
      }else if (mySplitResult[0] == 4){
         result = '<div class="msg">Your design should be in JPG format, 160 X 160 pixels<br> in dimension at72 dpi and not more than 400kb in size.<br>Please <a href=\'javascript:rewriteForm()\' style=\"color:#FF9900;\"><u>try</u></a> again.<\/div><br/><br/>';
	  }else if (mySplitResult[0] == 5){
         result = '<div class="msg">Your design should be in JPG format, 160 X 160 pixels<br> in dimension at72 dpi and not more than 400kb in size.<br>Please <a href=\'javascript:rewriteForm()\' style=\"color:#FF9900;\"><u>try</u></a> again.<\/div><br/><br/>';
	  } else {
         result = '<div class="emsg">There was an error during file upload!<br>Please <a href=\'javascript:rewriteForm()\' style=\"color:#FF9900;\"><u>try</u></a> again.<\/div><br/><br/>';
      }
      document.getElementById('f1_upload_process').style.visibility = 'hidden';
	  document.getElementById('f1_upload_form').innerHTML = result;
     //document.getElementById('f1_upload_form').innerHTML = result + '<label>File: <input name="myfile" type="file" size="30" /><\/label><label><input type="submit" name="submitBtn" class="sbtn" value="Upload" /><\/label>';
      document.getElementById('f1_upload_form').style.visibility = 'visible'; 
      return true;   
}

function rewriteForm(){
    document.getElementById('f1_upload_form').innerHTML = '<form action="upload.php" method="post" enctype="multipart/form-data" target="upload_target" onsubmit="return startUpload();" ><input name="myfile" id="myfile" type="file" size="40" style="font-family:Arial, Helvetica;font-size:12px;letter-spacing:1px;"/>&nbsp;<input name="submitBtn" Type="image" id="submitBtn" onmouseover="this.src=\'images/next_2.gif\'" onmouseout="this.src=\'images/next_1.gif\'" src="images/next_1.gif" align="middle" width="80" height="33" /></form>';
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function submitDescription(objFrm){
	if ((document.getElementById("designName").value!="") && (document.getElementById("designDescription").value!="")){
		return true;
	}else {
		if (document.getElementById("designName").value==""){
			document.getElementById("designName_alert").display="block";
			document.getElementById("designName_alert").style.visibility="visible";
			document.getElementById("designName_alert").innerHTML = "This is a required field";
		} else{
			document.getElementById("designName_alert").innerHTML = "";
			document.getElementById("designName_alert").display="none";
			document.getElementById("designName_alert").style.visibility="hidden";
		}
		if (document.getElementById("designDescription").value==""){
			document.getElementById("designDescription_alert").display="block";
			document.getElementById("designDescription_alert").style.visibility="visible";
			document.getElementById("designDescription_alert").innerHTML = "This is a required field";
		} else{
			document.getElementById("designDescription_alert").innerHTML = "";
			document.getElementById("designDescription_alert").display="none";
			document.getElementById("designDescription_alert").style.visibility="hidden";
		}
		return false;
	}
		//document.getElementById('f1_upload_process').style.visibility = 'visible';
		//document.getElementById('f1_upload_form').style.visibility = 'hidden';
	}
function registerToVote(obj){
	if (obj==1){
		document.getElementById('frm_container').style.display="none";
		document.getElementById('signup').style.display="block";
	} else if (obj==2){
		document.getElementById('frm_container').style.display="block";
		document.getElementById('signup').style.display="none";
	}
}

function checkForNum(o1){
	var NumValue = o1.value;
	var NumLen = NumValue.length;
	 if (isNaN(o1.value)){
	 	alert("This field is reserved for \"numbers\" only");
		o1.value = NumValue.substring(0,NumLen-1);
		o1.focus();
		return;
	 }
}
function voteSignDone(){
		document.getElementById('vote_loader').style.visibility="hidden";
		document.getElementById('vote_signthanks').style.visibility="visible";
		
}
function sendingVoteSign(){
		document.getElementById('signup').style.display="none";
		document.getElementById('vote_loader').style.visibility="visible";
		
}

function voteCount(){
			gShow = "voteCount";
			http.open("GET", getNumvoteURL, true);
			http.onreadystatechange = handleHttpResponse; 
			http.send(null);
}
	
function VoteForThis(){
	document.getElementById('voteTable').style.display="none";
	document.getElementById('vote_loader').style.visibility="visible";
}

function voteSignInDone(objValue){
	var mySplitResult = objValue.split("|");
		if (mySplitResult[0]=="welcome"){
			//alert(mySplitResult[1]+"--"+mySplitResult[2])
			//document.getElementById('frm_container').style.display="none";
			//document.getElementById('voteTable').style.display="block";
			//gShow = "voteCount";
			//http.open("GET", getNumvoteURL, true);
			//http.onreadystatechange = handleHttpResponse; 
			//http.send(null);
			location.href="../lock_voter.php?id="+mySplitResult[1]+"&select="+mySplitResult[2];
		} else {
			document.getElementById('returnMessage').innerHTML=objValue;
		}
	}
	
function returnToDirectory(){
		location.href="gallery.php";
	}

function voteDone(objValue){
	//alert("here")
	document.getElementById('vote_loader').style.visibility="hidden";
	document.getElementById('vote_thanks').style.visibility="visible";
	setTimeout("returnToDirectory()", 3000);
}

function CheckAge(obj){
	var NumValue = obj.value;
	var NumLen = NumValue.length;
	if (NumLen>1){
		 if (isNaN(obj.value)){
			alert("This field is reserved for \"numbers\" only");
			obj.value = "";
			obj.focus();
			return;
		 } else {
			if ((NumValue<13)||(NumValue>23)){
				 alert("The competition is open to \"youth aged 13 to 23 years old\".")
					obj.value = "";
					obj.focus();
					return;
			}  else if((NumValue>=13) && (NumValue<=16)) {
				document.getElementById('Category').value="Category A";
				
			} else if ((NumValue>=17) && (NumValue<=23)) {
				document.getElementById('Category').value="Category B";
			}
		}
	}
}

function private_select_tr(o1,o2){ // this, start_tr_id , global, tr_id, pass to
//private_select_tr(this,'Institution_ready')
			//<option value="Secondary School">Secondary School</option>
			//<option value="Junior College/Centralised Institute">Junior College / Centralised Institute</option>
			//<option value="ITE">ITE</option>
			//<option value="Polytechnic">Polytechnic</option>
			//<option value="University">University</option>
			//<option value="Madrasahs">Madrasahs</option>
			//<option value="Other Educational Institutions">Other Educational Institutions</option>
			//<option value="Other">Other</option>

if (school!=""){
		document.getElementById("Other_select").value="";
		document.getElementById(schoolKind+"_tr").style.display="none";
		school="";
		schoolKind="";
	}

	var thisTR = o1.value+"_tr";
	//alert("start:"+global_select_tr+" "+thisTR);
		document.getElementById('norm_man_Institution').value="";
		document.getElementById("Other_select").value="";
		document.getElementById("Other_tr").style.display="none";
	if (global_select_tr == ""){
			document.getElementById(o2).style.display="none";
	} else {
			document.getElementById(global_select_tr).style.display="none";
	}
	if (sniffer ==1){
			document.getElementById(thisTR).style.display="block";
			document.getElementById(o1.value+"_select").options[0].selected=true;

	}else{
			document.getElementById(thisTR).style.display="table-row";
			document.getElementById(o1.value+"_select").options[0].selected=true;
	}

		global_select_tr =  o1.value+"_tr";
		global_Institution = o1.value+"_select";
}


function public_passvalue(o1,o2){ // this, pass to
		document.getElementById(o2).value=o1.value;
}


function loadshirtIn(obj){
	document.getElementById('mydesignArea').style.background='url(images/'+obj+')';
	document.getElementById('2designcode').value = document.getElementById('1designcode').value;
	if (obj=="shirt_white.gif"){
		colorSend = 1;
	} else if (obj=="shirt_black.gif"){
		colorSend = 2;
	} else if (obj=="shirt_red.gif"){
		colorSend = 3;
	} else if (obj=="shirt_blue.gif"){
		colorSend = 4;
	} else if (obj=="shirt_yellow.gif"){
		colorSend = 5;
	} else if (obj=="shirt_green.gif"){
		colorSend = 6;
	}
	document.getElementById('tshirt').value=colorSend;
}

function PassDesignCode(){
	document.getElementById('designcode').value = document.getElementById('2designcode').value;
}

function ClipBoard(obj) {
	holdtext = document.getElementById(obj);
	//holdtext.innerText = copytext.innerText;
	Copied = holdtext.createTextRange();
	Copied.execCommand("Copy");
}


function NaviPage(o1){
	document.getElementById('page').value=o1;
	document.getElementById('MainFrm').submit()
}


// --> 
