// Common JavaScript code across your application goes here.

$(document).ready(function()
{
    $('#snap_click').click(function(){
       $("#contact_snap").css("display" ,  "");
    })
    $('#snap_close').click(function(){
       $("#contact_snap").css("display" ,  "none");
    })
    $("span[id^=snap]").hover(function(){
       $(this).css("cursor", "pointer");
    });
    //$('.splash_top').corner("top 15px");
   // $('.splash_bottom').corner("bottom 15px");
    $("select[id^=file]").change(function (ev) {
          var filename=$(this).val()
          controller=this.id.split(/_/)[1]
          var url='../' + controller + '/get_file?filename=' + escape(filename)
          newwindow=window.open(url, 'content_window')
          ev.preventDefault();
          return false
        })
/*
    $('#news_list').jcarousel({
       vertical: true,
       scroll: 1,
       visible: 4,
       wrap: 'last'
    });
*/
    $("#downForm").validate();
    $("#subForm").validate();

    $("#cchkagree").click(function () {
	if($(this).attr('checked')==true){
           $("#divsubmit").show()
           $("#user_agree").val("true")
        }
	else{
	   $("#divsubmit").hide();
           $("#user_agree").val("false")
	}
	});

}) //end of doucment.ready
	function chgBut(f){
		if(f.agree.checked==true){
			document.getElementById('subBut').style.visibility="visible"
			if(document.getElementById('subtype').value=="monthly"){
				document.getElementById('checktable').style.visibility="visible"
			}
		}
		else{
			document.getElementById('subBut').style.visibility="hidden"
		}
			
	}
	function setPayMethod(type){
		document.getElementById('paymethod').value=type
		butid=type + "chk"
		if(butid=="invoicechk"){
			document.getElementById('creditcardchk').checked=false
		}
		else{
			document.getElementById('invoicechk').checked=false
		}
	}
	function checkData(f){
	  	if (document.cookie==null){
			alert("The subscripiton process requires cookies.\nPlease enable cookies for this site.\nThank you ")
			return false
		}
       if(f.email.value==""){
               alert("Please fill in an email address");
               f.email.focus()
               return false;
       }
       else{
          var re = /.+@.+\..+/
          if(!re.test(f.email.value)){
               alert("Your email does not have a correct format!")
               f.email.focus()
               return false;
          }
       }
       if(f.fname.value==""){
          alert("Please fill in First Name.");
          f.fname.focus()
          return false;
       }
       if(f.org.value==""){
          alert("Please fill in company/org.");
          f.org.focus()
          return false;
       }
       if(f.lname.value==""){
               alert("Please fill in Last Name.");
               f.lname.focus()
               return false;
       }
       if(f.phone.value==""){
               alert("Please fill in a phone number.");
               f.phone.focus()
               return false;
       }
          if(f.staddress.value==""){
               alert("Please enter a street address")
               f.staddress.focus
               return false
          }
          if(f.city.value==""){
               alert("Please enter a city")
               f.city.focus
               return false
          }
       if(f.StateA.options[f.StateA.selectedIndex].value=="" && (f.country.value=="USA" || f.country.value=="usa" || f.country.value=="United Sates" || f.country.value=="Canada" || f.country.value=="CA" || f.country.value=="ca")){
          alert("Please select a state");
          f.StateA.focus();
          return false;
       }
       return true
  }


function chk_submit(){
   var ukname=$('#uname').val()
   var pkasswd=$('#passwd').val()
   if(ukname == ''){
       notify("please enter a user name")
       return false
   }
   if(pkasswd == ''){
       notify("Please enter a password")
       return false
   }
   if (document.cookie==null){
       notify("Login will only work when cookies are enabled for this site! ")
       return false
    }
    return true

}
function notify(msg){
   var notice = '<div class="notice">'
   + '<div class="notice-body">'
   + '<img src="../images/info.png" alt="" />'
   + '<h3>Alert!</h3>'
   + '<p>' + msg + '</p>'
   + '</div>'
   + '<div class="notice-bottom">'
   + '</div>'
   + '</div>';
   $( notice ).purr(
   {
      usingTransparentPNG: true
   }
   );
   return false;
}


