	
	function check_customerlogin(theForm) {
		var allOK = false;
		allOK = theForm.user.value != "" && theForm.pass.value != "";
		return allOK;
	}
/*	
	function footerLogin(theForm) {
		if (check_customerlogin(theForm)) {
			
			document.cookie= "fpuser" + "=" + escape(theForm.user.value) + "; path=/";
			document.cookie= "fppass" + "=" + escape(theForm.pass.value) + "; path=/";
			document.cookie= "fpclient" + "=" + escape(137) + "; path=/";		
		
			var url = "";
			url = "https://myaccount.sipdiscount.com//customerlogin/loginredirect.php?mode=fplogin";
			if (document.cookie == 'undefined' || document.cookie == "") {
				url= "https://myaccount.sipdiscount.com//customerlogin/loginredirect.php?client=137" + "&password="+theForm.pass.value+"&username="+theForm.user.value;
			}		
						
			newWin = window.open(url, "login", 'scrollbars=yes,status=yes,resizable,width=750,height=600');
			newWin.focus();			
			
			
		} else {
			alert("Incorrect user/password combination");
		}
		return false;
	}	
	*/
	function footerLogin(theForm) {
		if (check_customerlogin(theForm)) 
		{
				
			document.cookie= "fpuser" + "=" + escape(theForm.user.value) + "; path=/; domain=sipdiscount.com";
			document.cookie= "fppass" + "=" + escape(theForm.pass.value) + "; path=/; domain=sipdiscount.com";
				
		
			var url = "";
			url = "https://myaccount.sipdiscount.com/clx/?part=fplogin";
			if (document.cookie == 'undefined' || document.cookie == "") {
				url= "https://myaccount.sipdiscount.com/clx/?part=fplogin&password="+theForm.pass.value+"&username="+theForm.user.value;
			}		
			
			newWin = window.open(url, "login", 'scrollbars=yes,status=yes,resizable,width=800,height=600');
			newWin.focus();
			
		} else {
			alert("Incorrect user/password combination");
		}
		return false;
	}		
	
	function footerRegister() {
		var url= "https://myaccount.sipdiscount.com//customerlogin/profilecredit_update.php";
		newWin = window.open(url, "register", 'scrollbars=yes,status=yes,resizable,width=750,height=600');
		newWin.focus();
		return false;
	}	

	function isEmail(address) {
		var isValid = false;
		// basic checks (relying on lazy evaluation for correct behaviour!)
		// not empty
		// at least 7 characters (x@yy.zz)
		// has @
		// has only 1 @
		// has at least one . (domain.ext)
		isValid = (address!=null) 
		       && (address.length >= 7) 
		       && (address.indexOf('@')!=-1) 
		       && (address.indexOf('@') == address.lastIndexOf('@'))
		       && (address.indexOf('.')!=-1)
		;
		
		if (isValid) {
			var parts = address.split('@');
			var name  = parts[0].split('.');
			var host  = parts[1].split('.');
			var regName  = new RegExp("^([!#$%&*+-/0-9=?A-Z^_a-z{}~]+)$"); // at least length 1
			var regLabel = new RegExp("^(^[-0-9A-Za-z][-0-9A-Za-z]+)$"); // at least length 2
			var regExt   = new RegExp("^([A-Za-z]{2,63})$"); // at least length 2
			var i;
			for (i=0; i < name.length; i++) {
				isValid = isValid && (name[i].search(regName) != -1);
			}
			for (i=0; i < host.length-1; i++) {
				isValid = isValid && (host[i].search(regLabel) != -1) && (host[i].length <= 63);
			}
			isValid = isValid && (host[host.length-1].search(regExt) != -1);
		}
		return isValid;
	}	
	
	function checkRetrievePassword(thisform)
	{
		if (isEmail(thisform.email.value))
		{
		 	if (thisform.user.value!="") return true;
		 	else
		 	{
		 		alert("You are required to fill out all fields");
		 		return false;
		 	}
		}
		else 
		{
			alert("The entered email address is incorrect");
			return false;
		}
	}
	
	function checkNews()
	{
		if (isEmail(document.news.email.value))
		{
			document.news.submit();
			return true;
		}
		else 
		{
			alert("The entered email address is incorrect");
			return false;
		}
	}
	
	function checkNewsU()
	{
		if (isEmail(document.news2.email.value))
		{
			document.news2.submit();
			return true;
		}
		else 
		{
			alert("The entered email address is incorrect");
			return false;
		}
	}	

	function checkNewsMain(thisform)
	{
		if (isEmail(thisform.email.value))
		{			
			return true;
		}
		else 
		{
			alert("The entered email address is incorrect");
			return false;
		}
	}
	
	
	function getCookie(name)
	{
	    var dc = document.cookie;
	    var prefix = name + "=";
	    var begin = dc.indexOf("; " + prefix);
	    if (begin == -1)
	    {
	        begin = dc.indexOf(prefix);
	        if (begin != 0) return null;
	    }
	    else
	    {
	        begin += 2;
	    }
	    var end = document.cookie.indexOf(";", begin);
	    if (end == -1)
	    {
	        end = dc.length;
	    }
	    var s = dc.substring(begin + prefix.length, end);
	    s = s.replace(new RegExp("\\+", 'g'), "%20");
	    return unescape(s);
	}	

 	function getUserName()
 	{
 		if (document.cookie != 'undefined' && document.cookie != "") 
 		{	
 			return getCookie("voipusername");
 		}
 		else return "";
 	}	
 	
 	// iframe resize 
 	
 	//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["myframe"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller


