﻿/*PacketVideo.js
Global Javascript Functions for PacketVideo Website
******************************************************************/

/*  Global entroy point, starts when document is loaded
******************************************************************/
$(document).ready(function () {

	$('#SearchString').click(function() {
		this.value = "";	
	});
	
	$('#SearchString').blur(function() {
		Search(document.forms[0].SearchString.value);
	});
	
	
	$('#SearchString').keypress(function(e) {
            code= (e.keyCode ? e.keyCode : e.which);
            if (code == 13) {
				e.preventDefault();
				Search(document.forms[0].SearchString.value);
				this.value = "Search";
			}
     });
	
});

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 Search(obj) {
	/*if (obj.value.trim() == "")
		{
			obj.value = "Search";	
		} else {
			window.location = '/Search/?s=' + obj.value;	
		}
		*/
		window.location = '/Search/?s=' + obj;
}

function HighlightError(ops) {
    
	//Notify the user that there are errors

    //Remove Old Value
    $('#' + ops.target).attr('value', '');

    //Highlight the error
    $('label[for=' + ops.target + ']').css('color', Settings.green);
    $('#' + ops.target).css('background-color', Settings.yellow);
    $('#' + ops.target).css('color', Settings.green);

    //Clarify instrucitons on how to fix
    $('label[for=' + ops.target + ']').text(ops.text);
}

function RemoveHighlight(ops) {
    //Highlight the error
    $('label[for=' + ops.target + ']').css('color', Settings.white);
    $('#' + ops.target).css('background-color', Settings.green);

    //Clarify instrucitons on how to fix
    $('label[for=' + ops.target + ']').text(ops.label);
}

function TestEmail(ops) {
    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (filter.test($('#' + ops.target).attr('value'))) return true;
    else return false;
}
