
/************ HOMEPAGE SLIDER ************************/
/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/

function slideSwitch() {
    var $active = $('#home-slideshow A.active');

    if ( $active.length == 0 ) $active = $('#home-slideshow A:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#home-slideshow A:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}




/**************** CLEARS DEFAULT TEXT IN SEARCH FIELD ON FOCUS *************/
function clearIt(txt) {
    if(txt.value =="keyword or item #" || txt.value =="YOUR EMAIL HERE")
	{
		txt.value = "";
	}
	else
	{
		
	}
}


/***************** EMAIL SCRIPTS ******************/

/****** GRABS EMAIL AND SETS TO HIDDEN FORM INPUT VALUE ********/
function fillSpan(txt){
	var emailValue = document.getElementById('myEmail');
    emailValue.value = txt.value;
}


/******  TAKES THE EMAIL VALUE IN THE FOOTER AND SENDS IT VIA QUERY STRING TO THE EMAIL SIGN UP PAGE *********/
function queryEmail(){
    var theEmail = document.getElementById('myEmail'); 
	window.location ="\/t-email.aspx?email\="+theEmail.value;
}


/*******  GRABS THE VALUE OF THE EMAIL IF IT IS LOCATED IN THE QUERY STRING.  THIS SHOULD BE TYPICALLY BE SET FROM THE FOOTER EMAIL SUBMIT AREA  ***********/
function grabEmail()
{
	var userEmail = document.getElementById('email');
	if(userEmail)
	{
		var qrStr = window.location.search;
		var spQrStr = qrStr.substring(1);
		var arrQrStr = new Array();
		// splits each of pair
		var arr = spQrStr.split('&');
		
		for (var i=0;i<arr.length;i++){
			// splits each of field-value pair
			var index = arr[i].indexOf('=');
			var key = arr[i].substring(0,index);
			var val = arr[i].substring(index+1);
			
			// saves each of field-value pair in an array variable
			arrQrStr[key] = val;
		}
		
		if(!arrQrStr["email"])
		{
			
		}
		else
		{
			theEmail = arrQrStr["email"];
			userEmail.value = theEmail;
		}
	}
	else
	{
			
	}
}


/******** EMAIL SIGN-UP VALIDATION SCRIPTS GRABBED FROM EXISTING UCLA APPAREL WEBSITE *********/

function checkData(form)
{ 
	if (isEmpty(form.fname.value))
		alert("Please Enter first name");
	else if (isEmpty(form.lname.value))
		alert("Please Enter Last Name");
	else if (isEmpty(form.email.value))
		alert("Please Enter an E-mail Address");
	else if (isEmpty(form.confirm_email.value)) 
		alert("Please Enter an Confirmation E-mail Address");
	else if (form.email.value != form.confirm_email.value)
		alert("Please re-enter confirmation email address");
				
	else return validate(form);
				
	return false;
}
		
var misformattedFields = "";

function validate(form)
{	
	var returnValue = true;
	misformattedFields = EMAIL_ADDRaddrChk(document.getElementById('email').value);
	returnValue = isEmpty(misformattedFields);
	if(!returnValue)
	{
		alert(misformattedFields);
	}
	return returnValue;
}		

function isEmpty(s)
{   
	return ((s == null) || (s.length == 0) || (s == ""))
}
function EMAIL_ADDRaddrChk(EMAIL_ADDR) 
{
var ret="";	
if (EMAIL_ADDR == null || EMAIL_ADDR == "")
	ret = "A full email address must be entered";
else {
	if (EMAIL_ADDR.indexOf('"') != -1)
		ret = "Your email address cannot contain double quotes. ";
	if (EMAIL_ADDR.indexOf("'") != -1)
		ret += "Your email address cannot contain single quotes. ";
	if (EMAIL_ADDR.indexOf(",") != -1)
		ret += "Your email address cannot contain commas.";
	if (ret=="")
		if (EMAIL_ADDR.search(/^\S+\@\S+\.\S+$/) == -1)
			ret = "A full email address must be entered";
	}
return ret;
}
		
		



