function getWidth(extendfor, defW)
{
	ClearWidth = (window.innerWidth) ? window.innerWidth : document.body.clientWidth;
	brName = navigator.appName;
	brVer = parseInt(navigator.appVersion);
	if (brName == "Netscape" && brVer >= 4 || brName == "Microsoft Internet Explorer" && brVer >= 4) {
		ind = "1";
	}else if (brName == "Netscape" && brVer >= 3) {
		ind = "2";
	}else{
		ind = "3";
	}
	if (ind == "1" || ind =="2") {
		if (ind == "1") {
			var Rwidth=screen.width;
		}
		if (ind == "2") {
			var toolkit = java.awt.Toolkit.getDefaultToolkit();
			var screen_size = toolkit.getScreenSize();
			var Rwidth = screen_size.width;
		}
	 	if (Rwidth > 0 && ClearWidth > 0){
			if (Rwidth <= 640){
				if (Rwidth < 500){ ClearWidth = 95; }else{ ClearWidth = Math.round(((334+extendfor)/Rwidth)*1000)/10; }
			}else{
				if (Rwidth <= 800){
					if (ClearWidth < 500 || ClearWidth == 800){ ClearWidth = 42; }else{ ClearWidth = Math.round(((334+extendfor)/ClearWidth)*1000)/10; }
 		 		 }else{
				 	if (ClearWidth <= 500 || ClearWidth == Rwidth){
						ClearWidth = Math.round(1000*(Rwidth-654+extendfor)/Rwidth)/10;
					}else{
						if (ClearWidth > 812){ ClearWidth = Math.round(1000*(ClearWidth-654+extendfor)/ClearWidth)/10; }else{							ClearWidth = Math.round(((334+extendfor)/ClearWidth)*1000)/10;}
	 		 		 }
		 		 }
			}
		}else{
			ClearWidth = defW;
		}
	}else{
		if (ClearWidth < 1000) {
			ClearWidth = Math.round(((334+extendfor)/ClearWidth)*1000)/10} else {ClearWidth = Math.round(defW*ClearWidth/1000)
		};
	}
	return ClearWidth;
}
function getCenterWidth()
{
	ClearWidth = (window.innerWidth) ? window.innerWidth : document.body.clientWidth;
	brName = navigator.appName;
	brVer = parseInt(navigator.appVersion);
	if (brName == "Netscape" && brVer >= 4 || brName == "Microsoft Internet Explorer" && brVer >= 4) {
		ind = "1";
	}else if (brName == "Netscape" && brVer >= 3) {
		ind = "2";
	}else{
		ind = "3";
	}
	if (ind == "1" || ind =="2") {
		if (ind == "1") {
			var Rwidth=screen.width;
		}
		if (ind == "2") {
			var toolkit = java.awt.Toolkit.getDefaultToolkit();
			var screen_size = toolkit.getScreenSize();
			var Rwidth = screen_size.width;
		}
	 	if (Rwidth > 0 && ClearWidth > 0){
			if (Rwidth <= 640){
				if (Rwidth < 626){ ClearWidth = 95; }else{ ClearWidth = Math.round((468/Rwidth)*100); }
			}else{
				if (Rwidth <= 800){
					if (ClearWidth < 626 || ClearWidth == 800){ ClearWidth = 58; }else{ ClearWidth = Math.round((468/ClearWidth)*100); }
 		 		 }else{
				 	if (ClearWidth <= 626 || ClearWidth == Rwidth){
						ClearWidth = Math.round(100*(Rwidth-520)/Rwidth);
					}else{
						if (ClearWidth > 812){ ClearWidth = Math.round(100*(ClearWidth-520)/ClearWidth); }else{							ClearWidth = Math.round((468/ClearWidth)*100);}
	 		 		 }
		 		 }
			}
		}else{
			ClearWidth = 45;
		}
	}else{
		if (ClearWidth < 1000) {
			ClearWidth = Math.round(100*468/ClearWidth)} else {ClearWidth = Math.round(45*ClearWidth/1000)
		};
	}
	return ClearWidth;
}

function getExtendedCenterWidth()
{
	ClearWidth = (window.innerWidth) ? window.innerWidth : document.body.clientWidth;
	brName = navigator.appName;
	brVer = parseInt(navigator.appVersion);
	if (brName == "Netscape" && brVer >= 4 || brName == "Microsoft Internet Explorer" && brVer >= 4) {
		ind = "1";
	}else if (brName == "Netscape" && brVer >= 3) {
		ind = "2";
	}else{
		ind = "3";
	}
	if (ind == "1" || ind =="2") {
		if (ind == "1") {
			var Rwidth=screen.width;
		}
		if (ind == "2") {
			var toolkit = java.awt.Toolkit.getDefaultToolkit();
			var screen_size = toolkit.getScreenSize();
			var Rwidth = screen_size.width;
		}
	 	if (Rwidth > 0 && ClearWidth > 0){
			if (Rwidth <= 640){
				if (Rwidth < 626){ ClearWidth = 95; }else{ ClearWidth = Math.round((468/Rwidth)*100); }
			}else{
				if (Rwidth <= 800){
					if (ClearWidth < 626 || ClearWidth == 800){ ClearWidth = 58; }else{ ClearWidth = Math.round((468/ClearWidth)*100); }
 		 		 }else{
				 	if (ClearWidth <= 626 || ClearWidth == Rwidth){
						ClearWidth = Math.round(100*(Rwidth-347)/Rwidth);
					}else{
						if (ClearWidth > 812){ ClearWidth = Math.round(100*(ClearWidth-347)/ClearWidth); }else{							ClearWidth = Math.round((468/ClearWidth)*100);}
	 		 		 }
		 		 }
			}
		}else{
			ClearWidth = 55;
		}
	}else{
		if (ClearWidth < 1000) {
			ClearWidth = Math.round(100*(620)/ClearWidth)} else {ClearWidth = Math.round(55*ClearWidth/1000)
		};
	}
	return ClearWidth;
}

function addbookmark()
{
	var bookmarkurl="http://www.digitimes.com";
	var bookmarktitle="DigiTimes daily IT news";
	
	if (navigator.appName!="Netscape")
		{
			window.external.AddFavorite(bookmarkurl,bookmarktitle);
		}
	else
		{
			window.location = bookmarkurl;
		}
}
function JoinCheck(objForm) {
	if  (objForm.EMail.value == "") {
		alert ("Email is missing!");
		objForm.EMail.focus();
		return false;
	} else if (CheckEMail(objForm.EMail.value) == false) {
		alert("'"+objForm.EMail.value+"' entered has a problem. Please check it is correct and includes no spaces or special characters. If in doubt, please email 'zoran@digitimes.com'.");
		objForm.EMail.focus();
		return false;
	} else if (objForm.Password.value=="" ) {
		alert ("Password is missing!");
		objForm.Password.focus();
		return false;
	} else if (objForm.Password.value.length<4 ) {
		alert ("Password must be 4 characters!");
		objForm.Password.focus();
		return false;
	}
	return true;
}
function CheckEMail(mymail) {
	 n=mymail.length
	for (i=0; i< n; i++){
		if (((mymail.charCodeAt(i)==45) || (mymail.charCodeAt(i)==46) || (mymail.charCodeAt(i)==95) || ((mymail.charCodeAt(i)>=48) && (mymail.charCodeAt(i)<=57)) || ((mymail.charCodeAt(i)>=64) && (mymail.charCodeAt(i)<=90)) || ((mymail.charCodeAt(i)>=97) && (mymail.charCodeAt(i)<=122)))==false){
			return false;
			break;
			}
	}
			
	if (mymail.indexOf("@") < 1) {
		return false;
	}
	else if((mymail.indexOf("@")>(mymail.lastIndexOf(".")-2))||(mymail.lastIndexOf(".")==mymail.length-1)){
			return false;
	}
}
function CheckS(objForm) {
	ind=true;
	if (objForm.category.value == "") {
		alert ("News category is missing!");
		objForm.category.focus();
		ind=false;
	} else if  (objForm.newsletter.value == "") {
		alert ("Email address is missing!");
		objForm.newsletter.focus();
		ind=false;
		//*return false; *//
	} else if (CheckEMail(objForm.newsletter.value) == false) {
		alert("'"+objForm.newsletter.value+"' entered has a problem. Please check it is correct and includes no spaces or special characters. If in doubt, please email 'zoran@digitimes.com'.");
		objForm.newsletter.focus();
		ind=false;
		//*return false; *//
	} 
	if (ind==true){
		//*objForm.submit();
	}	
	return ind;
}
function MaxLen(Cnote) {
	if (Cnote.value.length >= 256) {
		fQC.Ccount.value=0;
		Cnote.value = Cnote.value.slice(0,255);
	}
	else {
		fQC.Ccount.value=255-Cnote.value.length;
	}
}
function CheckComment(objForm) {
	if (objForm.Cnote.value==""){
		alert ("You must enter a comment or question!");
		objForm.Cnote.focus();
		return false;
	}else{
		if ((objForm.CpY.checked == false) && (objForm.CpN.checked == false)){
			alert ("You must tell us if we can post your comment and/or question anonymously on the article page? [select Yes or No]");
			objForm.CpN.focus();
			return false;
		}else{
			if (objForm.Cdtm.value == ""){
				if (objForm.Creply.checked == true){
					if (objForm.Cemail.value == ""){
						alert('To receive an email reply, you must enter a valid Email address');
						objForm.Cemail.focus();
						return false;						
					}else{
						if (CheckEMail(objForm.Cemail.value) == false){
							alert("'"+objForm.Cemail.value+"' entered is not valid. Please check it is correct and includes no spaces or special characters. If in doubt, please email 'zoran@digitimes.com'.");
							objForm.Cemail.focus();
							return false;
						}else{
							return true;
						}
					}
				}else{
					if (objForm.Cemail.value == ""){
						return true;						
					}else{
						if (CheckEMail(objForm.Cemail.value) == false){
							alert("'"+objForm.Cemail.value+"' entered is not valid. Please check it is correct and includes no spaces or special characters. If in doubt, please email 'zoran@digitimes.com'.");
							objForm.Cemail.focus();
							return false;
						}else{
							return true;
						}
					}
				}
			}else{
				return true;
			}
		}	
	}	
}

function openSecondWindow(filename) {
	SecondWindow = window.open("","SecWin","width=580,height=360,resizable=yes,scrollbars=yes");
	SecondWindow.location.href = filename;
}

function UserControl(objForm) {
	if  (objForm.EMail.value == "") {
		alert ("Email is missing!");
		objForm.EMail.focus();
		return false;
	} else if (CheckEMail(objForm.EMail.value) == false) {
		alert("'"+objForm.EMail.value+"' entered has a problem. Please check it is correct and includes no spaces or special characters. If in doubt, please email 'zoran@digitimes.com'.");
		objForm.EMail.focus();
		return false;
	}
	return true;
}
