// JavaScript Document
<!--

function doChecks(form,field,status) {

var status = status;

if(status = 1) {

	 eval('document.'+form+'.'+field+'.checked=true');
	} else {
	eval('document.'+form+'.'+field+'.checked=false');
}
}


function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

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_callJS(jsStr) { //v2.0
  return eval(jsStr)
}




function MM_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); if (obj) obj.value = newText;
}


function enableField(form,fieldName)
{
	
	var newFieldsArray = fieldName.split('|');
	
	var quant = newFieldsArray.length;
	
	if(quant > 1) {
	
			
		for(var i=0;i<quant;i++) {
		
			eval('document.'+form+'.'+newFieldsArray[i]+'.disabled=false');
		
		}
		
	} else {
	
	eval('document.'+form+'.'+fieldName+'.disabled=false');
	
	}
	
}		


function disableField(form,fieldName)
{
	
	var newFieldsArray = fieldName.split('|');
	
	var quant = newFieldsArray.length;
	
	if(quant > 1) {
	
			
		for(var i=0;i<quant;i++) {
		
			eval('document.'+form+'.'+newFieldsArray[i]+'.disabled=true');
		
		}
		
	} else {
	
	eval('document.'+form+'.'+fieldName+'.disabled=true');
	
	}
	
}		
 
 function show(id){    
	var newIdsArray = id.split('|');
	
	var quant = newIdsArray.length;
	
	for(var i=0;i<quant;i++) {
    
	document.getElementById(newIdsArray[i]).style.display = 'inline';
     }
}

function hide(id){    

	var newIdsArray = id.split('|');
	
	var quant = newIdsArray.length;
	
	for(var i=0;i<quant;i++) {
    
     document.getElementById(newIdsArray[i]).style.display = 'none';
     }
}

function selectAll(f,n,v) {
		var chk   = ( v == null ? true : v );
		for (i = 0; i < f.elements.length; i++) {
			if( f.elements[i].type == 'checkbox' &&
f.elements[i].name == n ) {
				f.elements[i].checked = chk;
			}
		}
	}

function YY_checkform() { //v4.66
//copyright (c)1998,2002 Yaromat.com
  var args = YY_checkform.arguments; var myDot=true; var myV=''; var myErr='';var addErr=false;var myReq;
  for (var i=1; i<args.length;i=i+4){
    if (args[i+1].charAt(0)=='#'){myReq=true; args[i+1]=args[i+1].substring(1);}else{myReq=false}
    var myObj = MM_findObj(args[i].replace(/\[\d+\]/ig,""));
    myV=myObj.value;
    if (myObj.type=='text'||myObj.type=='password'||myObj.type=='hidden'){
      if (myReq&&myObj.value.length==0){addErr=true}
      if ((myV.length>0)&&(args[i+2]==1)){ //fromto
        var myMa=args[i+1].split('_');if(isNaN(myV)||myV<myMa[0]/1||myV > myMa[1]/1){addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==2)){
          var rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-z]{2,4}$");if(!rx.test(myV))addErr=true;
      } else if ((myV.length>0)&&(args[i+2]==3)){ // date
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);
        if(myAt){
          var myD=(myAt[myMa[1]])?myAt[myMa[1]]:1; var myM=myAt[myMa[2]]-1; var myY=myAt[myMa[3]];
          var myDate=new Date(myY,myM,myD);
          if(myDate.getFullYear()!=myY||myDate.getDate()!=myD||myDate.getMonth()!=myM){addErr=true};
        }else{addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==4)){ // time
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);if(!myAt){addErr=true}
      } else if (myV.length>0&&args[i+2]==5){ // check this 2
            var myObj1 = MM_findObj(args[i+1].replace(/\[\d+\]/ig,""));
            if(myObj1.length)myObj1=myObj1[args[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!myObj1.checked){addErr=true}
      } else if (myV.length>0&&args[i+2]==6){ // the same
            var myObj1 = MM_findObj(args[i+1]);
            if(myV!=myObj1.value){addErr=true}
      }
    } else
    if (!myObj.type&&myObj.length>0&&myObj[0].type=='radio'){
          var myTest = args[i].match(/(.*)\[(\d+)\].*/i);
          var myObj1=(myObj.length>1)?myObj[myTest[2]]:myObj;
      if (args[i+2]==1&&myObj1&&myObj1.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
      if (args[i+2]==2){
        var myDot=false;
        for(var j=0;j<myObj.length;j++){myDot=myDot||myObj[j].checked}
        if(!myDot){myErr+='* ' +args[i+3]+'\n'}
      }
    } else if (myObj.type=='checkbox'){
      if(args[i+2]==1&&myObj.checked==false){addErr=true}
      if(args[i+2]==2&&myObj.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
    } else if (myObj.type=='select-one'||myObj.type=='select-multiple'){
      if(args[i+2]==1&&myObj.selectedIndex/1==0){addErr=true}
    }else if (myObj.type=='textarea'){
      if(myV.length<args[i+1]){addErr=true}
    }
    if (addErr){myErr+='* '+args[i+3]+'\n'; addErr=false}
  }
  if (myErr!=''){alert('Oops, we need a little more information:\t\t\t\t\t\n\n'+myErr)}
  document.MM_returnValue = (myErr=='');
}

function MM_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); if (obj) obj.value = newText;
}




function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function P7_Snap() { //v2.65 by PVII
 var x,y,ox,bx,oy,p,tx,a,b,k,d,da,e,el,tw,q0,xx,yy,w1,pa='px',args=P7_Snap.arguments;a=parseInt(a);
 if(document.layers||window.opera){pa='';}for(k=0;k<(args.length);k+=4){
 if((g=MM_findObj(args[k]))!=null){if((el=MM_findObj(args[k+1]))!=null){
 a=parseInt(args[k+2]);b=parseInt(args[k+3]);x=0;y=0;ox=0;oy=0;p="";tx=1;
 da="document.all['"+args[k]+"']";if(document.getElementById){
 d="document.getElementsByName('"+args[k]+"')[0]";if(!eval(d)){
 d="document.getElementById('"+args[k]+"')";if(!eval(d)){d=da;}}
 }else if(document.all){d=da;}if(document.all||document.getElementById){while(tx==1){
 p+=".offsetParent";if(eval(d+p)){x+=parseInt(eval(d+p+".offsetLeft"));y+=parseInt(eval(d+p+".offsetTop"));
 }else{tx=0;}}ox=parseInt(g.offsetLeft);oy=parseInt(g.offsetTop);tw=x+ox+y+oy;
 if(tw==0||(navigator.appVersion.indexOf("MSIE 4")>-1&&navigator.appVersion.indexOf("Mac")>-1)){
  ox=0;oy=0;if(g.style.left){x=parseInt(g.style.left);y=parseInt(g.style.top);}else{
  w1=parseInt(el.style.width);bx=(a<0)?-5-w1:-10;a=(Math.abs(a)<1000)?0:a;b=(Math.abs(b)<1000)?0:b;
  x=document.body.scrollLeft+event.clientX+bx;y=document.body.scrollTop+event.clientY;}}
 }else if(document.layers){x=g.x;y=g.y;q0=document.layers,dd="";for(var s=0;s<q0.length;s++){
  dd='document.'+q0[s].name;if(eval(dd+'.document.'+args[k])){x+=eval(dd+'.left');y+=eval(dd+'.top');
  break;}}}e=(document.layers)?el:el.style;xx=parseInt(x+ox+a),yy=parseInt(y+oy+b);
 if(navigator.appVersion.indexOf("MSIE 5")>-1 && navigator.appVersion.indexOf("Mac")>-1){
  xx+=parseInt(document.body.leftMargin);yy+=parseInt(document.body.topMargin);}
 e.left=xx+pa;e.top=yy+pa;}}}
}


function setLocation(formName) {


form = eval('document.'+formName);

  var Current =form.elements["staffId"].selectedIndex;
	//document.write(Current);
	 // return false;
//document.forms[formCount].priceEach.options[Current].selected=true;
 
form.elements["locationId"].value = locations[Current];
}


function checkPanStatusChangeType() {

	form = document.forms[0];
	formname = document.forms[0].name;
	var currentIndex = form.panTypeId.options.selectedIndex;
	var currentType = form.panTypeId.options[currentIndex].value;
	
	if(currentType == 3) {
	
		enableField(formname,'statusChangeTypeId');
		alert('please specify the type of status change. you will be able to make additional changes after the first');
	}
}

function copyToList(formName,from,to)
{
	fromList = eval('document.forms[formName].' + from);
	toList = eval('document.forms[formName].' + to);
	if (toList.options.length > 0 && toList.options[0].value == 'temp')
	{
		toList.options.length = 0;
	}
	var sel = false;
	for (i=0;i<fromList.options.length;i++)
	{
		var current = fromList.options[i];
		if (current.selected)
		{
			sel = true;
			if (current.value == 'temp')
			{
				alert ('You cannot move this text!');
				return;
			}
			txt = current.text;
			val = current.value;
			toList.options[toList.length] = new Option(txt,val);
			fromList.options[i] = null;
			i--;
		}
	}
	if (!sel) alert ('You haven\'t selected any options!');
}

function allSelect(formName)
{
  List = document.forms[formName].chosen;
  var realChosen = new Array;
  if (List.length && List.options[0].value == 'temp') return;
  for (i=0;i<List.length;i++)
  {
     List.options[i].selected = true;
	 realChosen[i] = List.options[i].value;
  }
  
  document.forms[formName].realChosen.value = realChosen.join('|');
  
}


function showImage(which)
{

var thisIndex = document.swatchCat.elements[which].options.selectedIndex;
var imageNo = document.swatchCat.elements[which].options[thisIndex].value;
//alert(imageNo);
document.images[which].src = slides[imageNo];

}

// Cameron Gregory - cameron@bloke.com
// http://www.bloke.com
// http://www.bloke.com/javascript/Selector/
//
// ChangeLog
//
// Wed Jul 10 11:29:51 EDT 1996
//    Added -1 check on array
// Wed Jul 10 06:25:30 EDT 1996
//    merged pulldown and selector into one.
//
// Wed Jul 10 06:03:05 EDT 1996
//    3.0b5a hosed something! Stopped using Image objects
//    and just stored in array.
//
// Usage:
//  Selector(width,height,images)
//  SelectorLong(width,height,boxHeight,images)
//  SelectorLongNames(width,height,boxHeight,images,names)
//  PullDownSelector(width,height,images)
//  PullDownSelectorNames(width,height,images,names)
//
//     width, height	is image size (-1,-1) if you don't want to specify
//     boxHeight	is the height of the select box
//     images		is space or comma separated file list
//     names		is corresponding name array (comma separated)

function selectImage(f)
{
if (document.flipForm.which.selectedIndex >= 0)
  document.flipForm.flip.src = imageSet[document.flipForm.which.selectedIndex];
}

function SelectorLongNames(width,height,listHeight,images,names)
{
/* si: start index 
** i: current index
** ei: end index
** cc: current count
*/
 si = 0; 
 ci=0;
 cc=0;
 imageSet = new Array();
 ei = images.length;
  for (i=1;i<ei;i++) {
    if (images.charAt(i) == ' ' || images.charAt(i) == ',') {
      imageSet[cc] = images.substring(si,i);
      cc++;
      si=i+1;
      }
    }
  currentFlip = 0;
 si = 0; 
 ci=0;
 cc=0;
 nameSet = new Array();
 ei = names.length;
  for (i=1;i<ei;i++) {
    if (names.charAt(i) == ',') {
      nameSet[cc] = names.substring(si,i);
      cc++;
      si=i+1;
      }
    }
  currentFlip = 0;

  // should check nameSet.length == imageSet.length

  document.writeln("<FORM name=flipForm>");
  document.writeln("<table border=0><tr><td>");
  document.write("<img name='flip'");
  if (width >0)
    document.write("width="+width);
  if (height >0)
    document.write(" height=" +height);
  document.writeln(" src=" +imageSet[0]+ ">");
  document.writeln("</td><td>");

  document.write("<Select");
  if (listHeight > 0)
    document.write(" size="+listHeight);
  document.write(" name='which' onChange='selectImage(this.form)'>");

  for (i=0;i<imageSet.length;i++)
    if (i<nameSet.length)
      document.write("<OPTION value="+i+">"+nameSet[i]);
    else
      document.write("<OPTION value="+i+">"+imageSet[i]);

  document.writeln("</SELECT>");
  
  document.writeln("</FORM>");
 
 document.writeln("</td></tr></table>");
}


function SelectorLong(width,height,listHeight,images)
{
  SelectorLongNames(width,height,listHeight,images,",");
}

function PullDownSelector(width,height,images)
{
  SelectorLongNames(width,height,-1,images,",")
}

function PullDownSelectorNames(width,height,images,names)
{
  SelectorLongNames(width,height,-1,images,names)
}

// use -1 -1 if you don't know the width and height for the image
function Selector(width,height,images)
{
 listHeight=5;
  SelectorLong(width,height,listHeight,images);
}

function setNextStep(formName, nextStep) {
	

	document.forms[formName].nextStep.value = nextStep;
	
	
	
}

function requisites(action) {

	document.login.nextAction.value = action;
//	alert(action);

	if(action == 'login') {
	
		YY_checkform('login','emailAddr','#S','2','Please enter a valid email address','passwd','#q','0','Please enter your password');
		
	} else {
	
		YY_checkform('login','emailAddr','#S','2','Please enter a valid email address');
	}
}



function requireAll() {
	
	var err = new Array;
	form = document.addToCart;
	var count = 0;
	if(form.swatchId.value = null) {
		err[count] = 'Please select a fabric';
		count ++;
	}
	if(form.trimId.value =null) {
			err[count] = 'Please select a trim color';
			count ++;
	}
	if(form.sizeId.value=null) {
		err[count]='Please select a size';
		count ++;
	}
	
	var msg = err.join() + "<br />";
		
	if(msg!=null) {
		alert(msg);
	}
}

function OLD_FANCY_checkEntryCode() {
	
	form = document.media;
		
	var thisPromoCode = form.promoCode.value; // current promo code entered in form
	var initPromoCode = form.initPromoCode.value; // most recent promocode (either session or set by last loop)
	
	if(thisPromoCode!=initPromoCode) {
		form.termsCheck.value = 0;

		// see if they ahve a valid entry code
		for(e=0;e<entryCodes.length;e++) {
			if(thisPromoCode == entryCodes[e]) {
				var validCode = '1';
				var newCla = replaceAll(claText[e],"********","\n\n");
				form.initPromoCode.value = entryCodes[e];
			}
		}
		
		if(validCode == '1') {
		// they have entered a valid code
				form.claText.value = newCla;
				form.termsCheck.value = 1;
				form.submit.value = 'submit';
				alert('Please review the terms and conditions and click \'submit\'');
				
				return false;
		} else {
			
			alert('We did not recognize your entry code. Please re-enter it or leave the field blank');
			return false;
		}
	}  else { // promo code is the same as it was on last run-through
	
	
	    if(form.terms[1].checked) {
                alert('You must agree to the Content License Agreement to submit your mobisode for consideration.');
                return false;
        } else {

        YY_checkform('media','videoTitle','#q','0','Please enter a title','lengthSeconds','#q','0','Please provide the length in seconds','dateCreated','#q','0','Please provide the date or year created');return document.MM_returnValue;
	 }
}
	
}
	
function checkEntryCode() {
	
	form = document.media;
	var thisPromoCode = form.promoCode.value.toUpperCase();
	
//alert(thisPromoCode);
		
		// see if they ahve a valid entry code
		for(e=0;e<entryCodes.length;e++) {
			if(thisPromoCode == entryCodes[e]) {
				var validCode = '1';
			}
		}
		
		if(validCode == '1') {
			// they have entered a valid code
			YY_checkform('media','videoTitle','#q','0','Please enter a title','lengthSeconds','#q','0','Please provide the length in seconds','dateCreated','#q','0','Please provide the date or year created');return document.MM_returnValue;
			
		} else {
			
			alert('We did not recognize your entry code. Please re-enter it or leave the field blank');
			return false;
		}
}	


function replaceAll( str, from, to ) {
    var idx = str.indexOf( from );


    while ( idx > -1 ) {
        str = str.replace( from, to );
        idx = str.indexOf( from );
    }

    return str;
}


function isInt(myNum) {
         // get the modulus: if it's 0, then it's an integer
         var myMod = myNum % 1;

         if (myMod == 0) {
                 return true;
         } else {
                 return false;
         }
}


function forceAgreement() {
	
	form = document.cla;
		    if(form.terms[1].checked) {
                alert('You must agree to the license agreement to submit your mobisode for consideration');
                return false;
				
		} else {
			
			return true;
		}	
	
}
//-->