﻿function navigateParent() {
    if (validateFormNewsletter()){
    window.parent.location = "../index.aspx?pid=36&sid=0&g=loginregister&email=" + document.EmailSignup.txtEmailSignup.value;
   }
   }

function disBlockId(divname) {
   //document.getElementById(divname).style.display = "block";  
   document.FlvStrPlayer.javaCalls("stop"); 
}

function disNoneId(divname) {
    document.getElementById(divname).style.display = "none"; 
} 


function visShowId(divname) {
    document.getElementById(divname).style.visibility = "visible"; 
}

function visHideId(divname) {
    document.getElementById(divname).style.visibility = "hidden"; 
} 

function videoMaximize(cid) {
    OpenWindow = window.open("VideoMaximize.aspx?cid=" + cid,"flvFullScreenWin","width=750px","resizable=no","scrollbars=no","toolbar=no","location=no","status=no","menubar=no");
    //,"fullscreen=no","resizable=no","scrollbars=no","toolbar=no","location=no","status=no","menubar=no",
}

function VideoListsShowHide(ddlname)
{
    var posx = 0;
	var posy = 0;

    new Effect.toggle($(ddlname),'blind', {duration:0.4})
}


function BuyNow_MouseOver() {
    document.getElementById("buyNow").src = "images/gw-rec1-MouseOver.jpg"
}
function BuyNow_MouseOut() {
    document.getElementById("buyNow").src = "images/gw-rec1.jpg"
}

function pausecomp(millis) 
{
    var date = new Date();
    var curDate = null;

    do { curDate = new Date(); } 
    while(curDate-date < millis);
} 



function flashFullScreenClose(){
    disNoneId('divVideoFullscreen');
    visShowId('divVideo');
}


function openEmailLinkWindow(url){
    window.open('frmEmailLink.aspx?url=' + url,'EmailLink','width=415,height=260');
}
    
function buttondown( buttonname )
{
    if (document.images) {
      document[ buttonname ].src = eval( buttonname + "buttondown.src" );
    }
}

function buttonup ( buttonname )
{
    if (document.images) {
      document[ buttonname ].src = eval( buttonname + "buttonup.src" );
    }
}


function clearTextbox(txtbox) {
    if (txtbox.defaultValue == txtbox.value) txtbox.value = "";   
}



function validateFormVLogQuestion() {
    var reason = "";

    reason += validateEmpty(document.getElementById('_ctl0_cphMainContentBottom_txtFirsLasttName'), "Please enter your name");
    reason += validateEmail(document.getElementById('_ctl0_cphMainContentBottom_txtEmail'));
    reason += validateEmpty(document.getElementById('_ctl0_cphMainContentBottom_txtQuestion'), "Your forgot to ask your question, please enter one");

    if (reason != "") {
        alert("Some fields need to be completed:\n" + reason);
        return false;
    } else {
        document.getElementById('_ctl0_cphMainContentBottom_txtFirsLasttName').style.background = 'White';
        document.getElementById('_ctl0_cphMainContentBottom_txtEmail').style.background = 'White';
        document.getElementById('_ctl0_cphMainContentBottom_txtQuestion').style.background = 'White';
        return true;
    } 
}


function validateFormNewsletter() {
    var reason = "";

    reason += validateEmpty(document.getElementById('emailSignupTextbox'));

    if (reason != "" && reason!="» Enter your email address") {
        alert("Some fields need to be completed:\n");
        return false;
    } else {
        document.getElementById('emailSignupTextbox').style.background = 'White';
        return true;
    }
}


function validateFormGoogleSearch() {
    var reason = "";

    reason += validateEmpty(document.getElementById('searchTextbox'), "Please enter something to search by");

    if (reason != "") {
        alert("Some fields need to be completed:\n" + reason);
        return false;
    } else {
        document.getElementById('searchTextbox').style.background = 'White';
        return true;
    }
}


function validateEmpty(fld, errorText) {
    var error = "";

    if (fld.value.length == 0 | fld.value == fld.defaultValue) {
        fld.style.background = '#CCFFCC';
        error = errorText + "\n"
    } else {
        fld.style.background = 'White';
    }

    return error;
}


function trim(s) {
    return s.replace(/^\s+|\s+$/, '');
}

function validateEmail(fld) {
    var error = "";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/;
    var illegalChars = /[\(\)\<\>\,\;\:\\\"\[\]]/;

    if (fld.value == "" | fld.value == fld.defaultValue) {
        fld.style.background = '#CCFFCC';
        error = "Please enter an email address\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
    fld.style.background = '#CCFFCC';
        error = "Please enter a valid email address\n";
    } else if (fld.value.match(illegalChars)) {
    fld.style.background = '#CCFFCC';
        error = "The email address contains invalid characters\n";
    } else {
        fld.style.background = 'White';
    }
    return error;




}


function openTextAreaWindow(content) {

    top.consoleRef = window.open('', 'myconsole',
  'width=550,height=150'
   + ',menubar=0'
   + ',toolbar=1'
   + ',status=0'
   + ',scrollbars=1'
   + ',resizable=1')
    top.consoleRef.document.writeln(
  '<html><head><title>Embed Code</title></head>'
   + '<body bgcolor=white onLoad="self.focus()">'
   + '<textarea id=embedVideo rows=7 cols=60/>' + content + "</textarea>"
   + '</body></html>'
 )
    top.consoleRef.document.close()
}

