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_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_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 MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
*/

/**
*	DELAY MENUS v2
*	works with sub-sub menus as well
*/
var old_menus = [];
var delay = 700;

function MM_showHideLayers() {
	var i, p, v, obj, args = MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i += 3) {
		if ((obj=MM_findObj(args[i])) != null) {
			v = args[i+2];
			if (obj.style) {
				v = (v == 'show') ? 'visible' : (v == 'hide') ? 'hidden' : v;
				showhide(obj, v);
			}
		}
	}
}
function hideAllOthers()
{
	while(old_menus.length) {
		var menu = old_menus.pop();
		if(typeof menu.timeout != "undefined") window.clearTimeout(menu.timeout);
		menu.style.visibility = "hidden";
	}
}
function showhide(e, v)
{
	if(typeof e == "undefined") return;
	if(v == "visible") {
		hideAllOthers();
		if(typeof e.timeout != "undefined") window.clearTimeout(e.timeout);
		e.style.visibility = v;
	} else {
		if(typeof e.timeout != "undefined") window.clearTimeout(e.timeout);
		e.hideAfterDelay = function(){ var me = e; me.timeout = window.setTimeout(function(){ me.style.visibility = "hidden"}, delay) };
		e.hideAfterDelay();
		old_menus.push(e);
	}
}
/*---------------------------------------------------------*/


function toggleBlock(div){
	if(MM_findObj(div).style.display=='none'){ 
		MM_findObj(div).style.display = 'block';
	} else { MM_findObj(div).style.display = 'none'; }
	
}

function ValidateJoin() {
	if (document.getElementById('txtJoinOurMailinglist').value.length == 0) {
		document.getElementById('txtJoinOurMailinglist').focus();
		alert("Please enter your email");
		return false;
	} else if (!IsValidEmail(document.getElementById('txtJoinOurMailinglist').value)) {
		document.getElementById('txtJoinOurMailinglist').focus();
		return false;
	} else {
		return true;
	}
}

function IsValidEmail(txt){
	if(txt !="")
		{ 
			var goodEmail = txt.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
			if (goodEmail)
				{
					return true;
				} 
			else 
				{
					alert('Please make sure that you have entered a correct email format');
					return false;
				}
			return false;
		}		
	else
		{
			alert('Please enter your email');
				return false;
		}
}

 function handleKeyPress(e,btn){
	var key=e.keyCode || e.which;
	if (key==13){
		 e.returnValue=false; 
		 e.cancel = true; 
		 document.getElementById(btn).focus();
		 document.getElementById(btn).click();
	}
}

function ShowSpecs(x){
	if(MM_findObj("Specs"+x).style.display=='none'){ 
		MM_findObj("Specs"+x).style.display = 'block';
		MM_findObj("plus"+x).innerHTML = '<a href="javascript:ShowSpecs('+x+');">-</a>';
	} else { MM_findObj("Specs"+x).style.display = 'none';
		MM_findObj("plus"+x).innerHTML = '<a href="javascript:ShowSpecs('+x+');">+</a>'; }
	
}


function showjob(x){
	if(MM_findObj("job"+x).style.display=='none'){ 
		MM_findObj("job"+x).style.display = 'block';
	} else { MM_findObj("job"+x).style.display = 'none';
		 }
	
}

function validateContactForm(){	
	var msg="";
	if (!checkRadioButtons(document.Form1,'Contact1$grpUser')){
					msg +="- Choose the type of user\n"
				}
	else {
	    
	    // MOBI Account Details
		if (document.Form1.Contact1_rbtnExistingUser.checked == true){
			if (document.Form1.Contact1_txtUserName.value == "")
				msg +="- User Name (Login ID)\n" 
			if (document.Form1.Contact1_txtUTIDNumber.value == "")
				msg +="- UTID Number\n" 
			if (!checkRadioButtons(document.Form1,'Contact1$grpTerminal')){
					msg +="- Choose the type of user terminal\n"
				}	
		}	
	} 
	// Contact Information
	if (document.Form1.Contact1_txtContactName.value == "")
				msg +="- Contact Name\n" 
	if (document.Form1.Contact1_txtContactNumber.value == "")
				msg +="- Contact Number\n" 
	if (document.Form1.Contact1_txtEmail.value == "")
				msg +="- Email\n" 
	else
	{
		if( (document.Form1.Contact1_txtEmail.value.indexOf('@', 0) == -1) || (document.Form1.Contact1_txtEmail.value.indexOf('.') == -1) || (document.Form1.Contact1_txtEmail.value.indexOf(' ') > 0) || (document.Form1.Contact1_txtEmail.value.indexOf('#') > 0)) 
			msg +="- Valid Email Address\n" 
	}
		
	// Message			
	if (document.Form1.Contact1_ddlEnquiryType.value == "")
				msg +="- Enquiry Type\n" 
	if (document.Form1.Contact1_txtContactName.value == "")
				msg +="- Subject\n" 
	if (document.Form1.Contact1_txtMessage.value == "")
				msg +="- Your Message\n" 
	
	if (msg!=""){
		msg="Please enter the following information:\n" + msg
			alert(msg);
		return false;
		}
		else
	return true; 
	}	
	
function checkRadioButtons(theForm,theGroup)
{
   var bRadioChecked;
   var theElement;
   
   bRadioChecked = false;
   // loop through all elements on form
   for (var iElement = 0; iElement < theForm.length;iElement++)
   {  
      theElement = theForm[iElement];
	  // if it is a radio button within the group
      if ((theElement.type == "radio") && (theElement.name == theGroup))
      {
			if (theElement.checked == true)
			{
				bRadioChecked = true;
			}        
      }
   }
   if (bRadioChecked == false)
   {
    return false;
   }
   return true;
}

function ShowAccountDetails(flag)
{

    var vflag;
    vflag = flag;
   
    
    if (vflag == false)
    {
        for (var i = 1; i < 10; i++)
        {
            document.getElementById('div' + i).style.display = "block";
        }
    }
    else
    {
        for (var i = 1; i < 10; i++)
        {
            document.getElementById('div' + i).style.display = "none";
        }
    }
    document.getElementById('tblForm').style.width = "500px";
}

function getVar(name){
                var str = document.location.href;
                if (str.indexOf("?") != -1){
                                arr1 = str.split("?");
                                arr = arr1[1].split("&");
                                for (var i = 0; i<arr.length;i++){
                                                a = arr[i].split("=");
                                                if (a[0] == name){
                                                                return unescape(a[1]);
                                                }
                                }
                }
                return " ";
}


function getDistricts(url){
	$("#ddlDistrict").html("<option>Loading...</option>");
	$.get(url, function(data){
          $("#ddlDistrict").html(data); 
	}); 
}

function getCities(url){
	$("#ddlCity").html("<option>Loading...</option>");
	$.get(url, function(data){
          $("#ddlCity").html(data); 
	}); 
}

function getPOS(url){
	$("#divPOS").html("Loading...");
	$.get(url, function(data){
          $("#divPOS").html(data); 
	}); 
}

function getDistrictsCoverage(url){
	$("#CoverageRequest1_ddlDistrict").html("<option>Loading...</option>");
	$.get(url, function(data){
          $("#CoverageRequest1_ddlDistrict").html(data); 
	}); 
}

function getCitiesCoverage(url){
	$("#CoverageRequest1_ddlCity").html("<option>Loading...</option>");
	$.get(url, function(data){
          $("#CoverageRequest1_ddlCity").html(data); 
	}); 
}

function getDistrictsRegisterAndWin(url){
	$("#RegisterAndWin1_ddlDistrict").html("<option>Loading...</option>");
	$.get(url, function(data){
          $("#RegisterAndWin1_ddlDistrict").html(data); 
	}); 
}

function getCitiesRegisterAndWin(url){
	$("#RegisterAndWin1_ddlCity").html("<option>Loading...</option>");
	$.get(url, function(data){
          $("#RegisterAndWin1_ddlCity").html(data); 
	}); 
}

function validateCoverageRequestForm(){	
	var msg="";
	
	if (document.Form1.CoverageRequest1_ddlplans.value == "")
				msg +="- Choose your desired Monthly Plan\n" 
	if (document.Form1.CoverageRequest1_txtFirstName.value == "")
				msg +="- Contact Name\n" 
	if (document.Form1.CoverageRequest1_txtLastName.value == "")
				msg +="- Contact Number\n" 
	if (document.Form1.CoverageRequest1_txtEmail.value == "")
				msg +="- Email\n" 
	else
	{
		if( (document.Form1.CoverageRequest1_txtEmail.value.indexOf('@', 0) == -1) || (document.Form1.CoverageRequest1_txtEmail.value.indexOf('.') == -1) || (document.Form1.CoverageRequest1_txtEmail.value.indexOf(' ') > 0) || (document.Form1.CoverageRequest1_txtEmail.value.indexOf('#') > 0)) 
			msg +="- Valid Email Address\n" 
	}
		
	// Message			
	if (document.Form1.CoverageRequest1_ddlCity.value == "")
				msg +="- City\n" 
	if (document.Form1.CoverageRequest1_ddlhear.value == "")
				msg +="- How did you hear about Mobi?\n" 
	if (document.Form1.CoverageRequest1_txtAddress.value == "")
				msg +="- Your Address\n" 
	
	if (msg!=""){
		msg="Please enter the following information:\n" + msg
			alert(msg);
		return false;
		}
		else
	return true; 
	}
	
	function validateRegisterAndWinForm(){	
	var msg="";
	
	if (document.Form1.RegisterAndWin1_txtFirstName.value == "")
				msg +="- Contact Name\n" 
	if (document.Form1.RegisterAndWin1_txtLastName.value == "")
				msg +="- Contact Number\n" 
	if (document.Form1.RegisterAndWin1_txtTel.value == "")
				msg +="- Telephone\n" 
	if (document.Form1.RegisterAndWin1_txtEmail.value == "")
				msg +="- Email\n" 
	else
	{
		if( (document.Form1.RegisterAndWin1_txtEmail.value.indexOf('@', 0) == -1) || (document.Form1.RegisterAndWin1_txtEmail.value.indexOf('.') == -1) || (document.Form1.RegisterAndWin1_txtEmail.value.indexOf(' ') > 0) || (document.Form1.RegisterAndWin1_txtEmail.value.indexOf('#') > 0)) 
			msg +="- Valid Email Address\n" 
	}
		
	// Message			
	if (document.Form1.RegisterAndWin1_ddlUniversity.value == "")
				msg +="- University\n" 
	if (document.Form1.RegisterAndWin1_ddlMajor.value == "")
				msg +="- Major\n" 
	if (document.Form1.RegisterAndWin1_ddlCity.value == "")
				msg +="- City\n" 
	if (document.Form1.RegisterAndWin1_txtAddress.value == "")
				msg +="- Your Address\n" 
	
	if (msg!=""){
		msg="Please enter the following information:\n" + msg
			alert(msg);
		return false;
		}
		else
	return true; 
	}
	
	
function newWindow(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight) {
  var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
  var int_windowTop = (screen.height - a_int_windowHeight) / 2;
  var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft;
  var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
    if (parseInt(navigator.appVersion) >= 4) {
      obj_window.window.focus();
    }
}