function externalLinks() {
	var appName = navigator.appName.toLowerCase();
	if(appName.indexOf("explorer")<0){
		set_items();
	}
	else{
		var ieVerX = navigator.appVersion.split("MSIE");
		var ieVer = parseFloat(ieVerX[1]);
		if(ieVer>6){ set_items(); }
	}
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	var hareas = document.getElementsByTagName("area");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if(anchor.attributes.getNamedItem("rel")){ if(anchor.attributes.getNamedItem("rel").value == "out"){ anchor.target = "_blank"; } }
	}
	for (var i=0; i<hareas.length; i++) {
		var harea = hareas[i];
		if(harea.attributes.getNamedItem("rel")){ if(harea.attributes.getNamedItem("rel").value == "out"){ harea.target = "_blank"; } }
	}
	start_timer();
}
window.onload = externalLinks;

function set_items(){
		var trnsArea1 = document.getElementById("menu-items");
		trnsArea1.style.backgroundImage = "url('/2007/images/menu-middle.png')";
		trnsArea1.style.backgroundRepeat = "repeat-y";

		var trnsArea2 = document.getElementById("text-area");
		trnsArea2.style.backgroundImage = "url('/2007/images/clamp-middle.png')";
		trnsArea2.style.backgroundRepeat = "repeat-y";

		var trnsArea3 = document.getElementById("clamp-bottom");
		trnsArea3.style.backgroundImage = "url('/2007/images/clamp-bottom.png')";
		trnsArea3.style.backgroundRepeat = "repeat-y";
}


function start_timer(){
	if(document.getElementById("timebomb")){
		var tDiv = document.getElementById("timebomb");
		var timeNow = new Date();
		var timeTarget = new Date(2007,3-1,2,20,0,0);
		var timeRemain = ( timeTarget.getTime() - timeNow.getTime() ) / 1000;

		if(timeRemain>0){
			var secondsLeft = Math.floor(timeRemain % 60);
			timeRemain/= 60;
			
			var minutesLeft = Math.floor( timeRemain % 60);
			timeRemain/= 60;
			
			var hoursLeft = Math.floor( timeRemain % 24);
			timeRemain/= 24;
			
			var daysLeft = Math.floor(timeRemain % 30);
			timeRemain/= 30;
			
			var monthsLeft = Math.floor(timeRemain);
			var outPutString = "";

			if(monthsLeft>-1){ if(monthsLeft<10){monthsLeft="0"+monthsLeft;} outPutString+= monthsLeft + ":"; }
			if(daysLeft>-1){ if(daysLeft<10){daysLeft="0"+daysLeft;} outPutString+= daysLeft + ":"; }
			if(hoursLeft>-1){ if(hoursLeft<10){hoursLeft="0"+hoursLeft;} outPutString+= hoursLeft + ":"; }
			if(minutesLeft>-1){ if(minutesLeft<10){minutesLeft="0"+minutesLeft;} outPutString+= minutesLeft + ":"; }
			if(secondsLeft>-1){ if(secondsLeft<10){secondsLeft="0"+secondsLeft;} outPutString+= secondsLeft; }
			
			if(outPutString.substring(outPutString.length-1,outPutString.length) == ":"){
				outPutString = outPutString.substring(0,outPutString.length-1);
			}

			tDiv.innerHTML = outPutString;
			setTimeout("start_timer()",1000);
		}
	}
}



function check_form(form_object){
	if(form_object){
		for(var i=0;i<form_object.elements.length;i++){
			var form_item = form_object.elements[i];
			var form_value = form_item.value;
			var form_length = form_value.length;
			var form_disabled = form_item.disabled;

			// number --------------------------------------------------------------------
			var form_command = form_item.attributes.getNamedItem("number");
			if(form_command&&!form_disabled){
				if(isNaN(form_value)||form_length==0){
					if(form_command.value.length>0){alert(form_command.value);}
					form_item.value = "";
					form_item.focus();
					return false;
				}
			}
			// number --------------------------------------------------------------------

			
			// regex ---------------------------------------------------------------------
			var form_command = form_item.attributes.getNamedItem("regex");
			var error_command = form_item.attributes.getNamedItem("regex_error");
			var not_req = form_item.attributes.getNamedItem("notreq");
			var execute_action = true;
			if(form_command&&!form_disabled){
				if(not_req&&form_length==0){ execute_action = false; }
				if(execute_action){
					var oPattern = form_command.value;
					var oReg = new RegExp(oPattern,"gim");
					var oRegResult = oReg.test(form_value);
					if(!oRegResult){
						if(error_command.value.length>0){alert(error_command.value);}
						form_item.value = "";
						form_item.focus();
						return false;
					}
				}
				
			}
			// regex ---------------------------------------------------------------------
			
			// email ---------------------------------------------------------------------
			var form_command = form_item.attributes.getNamedItem("email");
			var not_req = form_item.attributes.getNamedItem("notreq");
			var execute_action = true;
			if(form_command&&!form_disabled){
				if(not_req&&form_length==0){ execute_action = false; }
				if(execute_action){
					if(!reg_exp(form_value,/^[\w\.\-]+@[\w\.\-]+$/gim)){
						if(form_command.value.length>0){alert(form_command.value);}
						form_item.value = "";
						form_item.focus();
						return false;
					}
				}
				
			}
			// email ---------------------------------------------------------------------
			
			// url   ---------------------------------------------------------------------
			var form_command = form_item.attributes.getNamedItem("url");
			var not_req = form_item.attributes.getNamedItem("notreq");
			var execute_action = true;
			if(form_command&&!form_disabled){
				if(not_req&&form_length==0){ execute_action = false; }
				if(execute_action){
					if(!reg_exp(form_value,/^(http\:\/\/)?[\w|\/|\.|\~|\-]+[\.][\w]+$/gim)){
						if(form_command.value.length>0){alert(form_command.value);}
						form_item.value = "";
						form_item.focus();
						return false;
					}
				}
				
			}
			// url   ---------------------------------------------------------------------

			// notempty ------------------------------------------------------------------
			var form_command = form_item.attributes.getNamedItem("notempty");
			if(form_command&&!form_disabled&&form_length==0){
				if(form_command.value.length>0){alert(form_command.value);}
				form_item.focus();
				return false;
			}
			// notempty ------------------------------------------------------------------
			
			// minlength -----------------------------------------------------------------
			var form_command = form_item.attributes.getNamedItem("minlength");
			var error_command = form_item.attributes.getNamedItem("minlength_error");
			if(form_command&&!form_disabled){
				if(form_length<form_command.value){
					if(error_command&&error_command.value.length>0){alert(error_command.value);}
					form_item.focus();
					return false;
				}
			}
			// minlength -----------------------------------------------------------------
			
			// maxchar -------------------------------------------------------------------
			var form_command = form_item.attributes.getNamedItem("maxchar");
			var error_command = form_item.attributes.getNamedItem("maxchar_error");
			if(form_command&&!form_disabled){
				if(form_length>form_command.value){
					if(error_command&&error_command.value.length>0){alert(error_command.value);}
					form_item.value = "";
					for(var q=0;q<form_command.value;q++){ form_item.value+= form_value.charAt(q); }
					form_item.focus();
					return false;
				}
			}
			// maxchar -------------------------------------------------------------------

		}
		return true;
		//return false;
	}
	else {
		alert("check html code! (return check_form(this);)");
		return false;
	}
}

function reg_exp(source_string,reg_pattern){
	var reg = new RegExp(reg_pattern);
	return (reg.test(source_string));
}

function upload_only(oFormObj){
	var Step1 = check_form(oFormObj);
	if(Step1){
		document.getElementById("uploadbutton").disabled = true;
		alert("Uploading will start! Please wait till the end!");
		return true;
	}
	else{
		return false;
	}
}