// BrowserCheck Object
function BrowserCheck() {
	var u = navigator.userAgent.toLowerCase();
	this.u = u
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	if(this.b=="ie" && this.u.indexOf('opera')!=-1) 
	this.b = "op"
	this.version = navigator.appVersion
	this.v = parseInt(this.version)
	this.op = (this.b=="op")
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie5 = (this.version.indexOf('MSIE 5')>0)
	this.ie6 = (this.version.indexOf('MSIE 6')>0)	
	this.ie7 = (this.version.indexOf('MSIE 7')>0)
	this.ie8 = (this.version.indexOf('MSIE 8')>0)			
	this.min = (this.ns||this.ie)
}
is = new BrowserCheck();

function checkMail(sInputValue,cFormField){
	var myRe = /[a-z0-9_.=-]+@([a-z0-9-]+\.)+([a-z]{2,3})/i;
	if (!(sInputValue).match(myRe))	{
		alert(s_wrongmail_Alert)
		cFormField.focus()
		return false
	}
	else {
		return true
	}
}

function IsNumeric(sText) { 
   var ValidChars = "0123456789."; 
   var Char;
   var bCase = true
   for (i = 0; i < sText.length; i++) {
       Char = sText.charAt(i);
       if (ValidChars.indexOf(Char) == -1) {
          bCase = false;
       }
    }
	return  bCase;
}

function checkContactForm(oForm){
	var oForm = document.forms["contactForm"]
	return checkMail(oForm.Email.value, oForm.Email)
}

function checkTipsForm(){
	var oForm = document.forms["tipsForm"]
	if(checkMail(oForm.receiverEmail.value, oForm.receiverEmail)){
		return checkMail(oForm.senderEmail.value, oForm.senderEmail)
	}
	else return false
}



function checkMaillistForm(sInputValue){
	/*
	if(document.forms['maillistForm'].MemberName.value ==""){
		alert(noNameML);
		document.forms['maillistForm'].MemberName.focus();
		return false;
	}
	else{
		*/
		var myRe = /[a-z0-9_.=-]+@([a-z0-9-]+\.)+([a-z]{2,3})/i;
		if (!(sInputValue).match(myRe))	{
			alert(emailErrorML);
			document.forms['maillistForm'].MemberEmail.focus()
			return false
		}
		else {
			if(document.forms['maillistForm'].Status[0]!=null) document.forms['maillistForm'].SubmitMode.value = (document.forms['maillistForm'].Status[0].checked)? "create":"delete"
			return true
		}
	//}
}		

function checkMail(sInputValue,oFormField){
	var myRe = /[a-z0-9_.=-]+@([a-z0-9-]+\.)+([a-z]{2,3})/i;
	if (!(sInputValue).match(myRe))	{
		alert(emailErrorML)
		oFormField.focus()
		return false
	}
	else {
		return true
	}
}

function addBookmark(title,url) {
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,""); 
	} else if( document.all ) {
		window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
		return true;
	}
}

function checkSuscriptionForm(oForm, sInputValue){
	
	if(oForm.Name.value ==""){
		alert(noNameSusc);
		oForm.Name.focus();
		return false;
	}
	if(oForm.LastName.value ==""){
		alert(noLastNameSusc);
		oForm.LastName.focus();
		return false;
	}
	if(oForm.Address.value ==""){
		alert(noAddressSusc);
		oForm.Address.focus();
		return false;
	}
	if(oForm.City.value ==""){
		alert(noCitySusc);
		oForm.City.focus();
		return false;
	}
	if(oForm.CP.value ==""){
		alert(noCPSusc);
		oForm.CP.focus();
		return false;
	}
	if(oForm.Country.value ==""){
		alert(noCountrySusc);
		oForm.Country.focus();
		return false;
	}
					
	var myRe = /[a-z0-9_.=-]+@([a-z0-9-]+\.)+([a-z]{2,3})/i;
	if (!(sInputValue).match(myRe))	{
		alert(emailErrorML);
		oForm.Email.focus()
		return false
	}
	/**/
	var ifChecked = false
	for(i=0; i<oForm.SuscriptionChoose.length;i++){
		if(oForm.SuscriptionChoose[i].checked) oForm.FramNo.value = eval('oForm.SuscriptionChooseNo'+i).value;
	}
	if(!oForm.SuscriptionChoose[0].checked&&!oForm.SuscriptionChoose[1].checked&&!oForm.SuscriptionChoose[2].checked){
		alert(noSuscriptionChooseSusc)
		return false
	}
	if(!oForm.PayForm[0].checked&&!oForm.PayForm[1].checked){
		alert(noPayFormSusc)
		return false
	}
	/**/	
	return true
}	

function resend(sDate, iListID, iMailContentId, sTitle){
    var newUrl = hostPath + "/web/resend.asp?sDate="+sDate+"&ListID="+iListID+"&MailContentId="+iMailContentId+"&sTitle="+sTitle;
    //alert(newUrl)
    window.open(newUrl,"ReSend","width=590,height=450,resizable=yes,scrollbars=yes")
}

function findPos(obj,cPos) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}								
		while (obj = obj.offsetParent);
	}
	return (cPos=="left")? curleft:curtop;
}
function setEditorialSelectBox(oObj, iCase){
	if(is.ie){
		var oLeft = findPos(document.getElementById('editorialSel'),"left")
		var oTop = findPos(document.getElementById('editorialSel'),"top")
		document.getElementById("spanImg").style.paddingBottom = 18;
		if(oObj.style.position !=  "absolute"){
			oObj.style.position =  "absolute";
			oObj.style.left = oLeft;
			oObj.style.top = oTop + 2;
		}
		if(iCase==1){
			oObj.style.width = 344;
		}
		else{
			oObj.style.width = 170;
		}
	}
}

function loadListwithAuthor(iID){
	var cObj = document.getElementById("authorNameLink");
	if(cObj!=null&&cObj!="underfined"){
		//alert(hostPath+'/web/article.asp?artID=17568&artAuthorName='+cObj.name)
		document.location.href = hostPath+'/web/article.asp?artID=17568&artAuthorName='+cObj.name;
	}
}
