// JavaScript Document
function delEmail(field){
	if(field.value=="Enter e-mail")	field.value="";
}
function resEmail(field){
	if(field.value=="")	field.value="Enter e-mail";
}



function delzip(field){
	if(field.value=="State, City or Zip Code")	field.value="";
}
function reszip(field){
	if(field.value=="")	field.value="State, City or Zip Code";
}


/** POPUP : priorizar que las medidas sean inferiores a la resolucion de la pantalla **/
function getcollectionvideo(id,pos) {
	var vwidth = 770;
	var vheight = 568;
	window.open('video.php?id='+id+'&pos='+pos,'vids','toolbar=no,location=no,directories=no,menubar=no,status=0,scrollbars=no,resizable=no,width='+vwidth+',height='+vheight+',top='+((window.screen.height/2)-(vheight/2))+',left='+((window.screen.width/2)-(vwidth/2))+'\'');
}


function submitin() {
	vwidth = 770;
	vheight = 545;
		stopt();
		window.open('popup.php','pops','toolbar=no,location=no,directories=no,menubar=no,status=no,scrollbars=no,resizable=no,width='+vwidth+',height='+vheight+',top='+((window.screen.height/2)-(vheight/2))+',left='+((window.screen.width/2)-(vwidth/2))+'\'');
		document.forchu.submit();
	}

function submitintop() {
 
	var vwidth = 770;
	var vheight = 545;
		window.open('popup.php','pops','toolbar=no,location=no,directories=no,menubar=no,status=no,scrollbars=no,resizable=no,width='+vwidth+',height='+vheight+',top='+((window.screen.height/2)-(vheight/2))+',left='+((window.screen.width/2)-(vwidth/2))+'\'');
		document.forchutop.submit();
	}

function submitinnews() {
	var vwidth = 770;
	var vheight = 545;
		window.open('popup.php','popup','toolbar=no,location=no,directories=no,menubar=no,status=no,scrollbars=no,resizable=no,width='+vwidth+',height='+vheight+',top='+((window.screen.height/2)-(vheight/2))+',left='+((window.screen.width/2)-(vwidth/2))+'\'');
		document.forchu.submit();
	}
	
function submitinvideo(lo) {
	var vwidth = 770;
	var vheight = 520;
		window.open('video.php','vids','toolbar=no,location=no,directories=no,menubar=no,status=0,scrollbars=no,resizable=no,width='+vwidth+',height='+vheight+',top='+((window.screen.height/2)-(vheight/2))+',left='+((window.screen.width/2)-(vwidth/2))+'\'');
		document.forchuvideo.action = "video.php?id="+lo;
		document.forchuvideo.submit();
	}
	
function counter_text(field, countfield, maxlimit) {
        if (field.value.length > maxlimit){
                field.value = field.value.substring(0, maxlimit);
                countfield.innerText = maxlimit - field.value.length;
        }
        else  {
                countfield.innerText = maxlimit - field.value.length;
        }
}
		

function automat(seg)
{
	tiempo = parseInt(seg);

	if (isNaN(tiempo) || tiempo <= 0)
		alert("Error en el tiempo")
	else
		tempor = setTimeout("pasar()", tiempo)
}

function stopt()
{
	if (typeof(tempor) != "undefined")
		clearTimeout(tempor);
}

function pasar()
{
	cambio(1);
	if (contador < largo-1)
	tempor = setTimeout("pasar()", tiempo);
	if	(contador == largo-1){
		contador = -1;
		tempor = setTimeout("pasar()", tiempo);
	}
}

/**************************************************************************************/

function nowdate(){
	var date = new Date();
	var hour = date.getHours();
	var mins = date.getMinutes();
	var segs = date.getSeconds();
	
	if(hour >12)hour= hour-12;
	
	hour = (hour < 10)?"0"+hour:hour;
	mins = (mins < 10)?"0"+mins:mins;
	segs = (segs<10)?"0"+segs:segs;

	var dayn = date.getDay();
	var monthn = date.getMonth();
	var yearn = date.getYear();
	var daymonth = date.getDate();


switch (dayn) {
    case 0:
      day = "Sunday";
      break;
    case 1:
      day = "Monday";
      break;
    case 2:
      day = "Tuesday";
      break;
    case 3:
      day = "Wednesday";
      break;
    case 4:
      day = "Thursday";
      break;
    case 5:
      day = "Friday";
      break;
    case 6:
      day = "Saturday";
      break;
  };

switch (monthn) {
    case 0:
      month = "January";
      break;
    case 1:
      month = "February";
      break;
    case 2:
      month = "March";
      break;
    case 3:
      month = "April";
      break;
    case 4:
      month = "May";
      break;
    case 5:
      month = "June";
      break;
    case 6:
      month = "July";
      break;
    case 7:
      month = "August";
      break;
    case 8:
      month = "September";
      break;
    case 9:
      month = "October";
      break;
    case 10:
      month = "November";
      break;
    case 11:
      month = "December";
      break;
  }

document.write(day+", "+month+" "+daymonth+" "+yearn+" "+hour+":"+mins+" DST");
}

function showFlash(movie,w,h){
	document.write("<object type=\"application/x-shockwave-flash\" width=\""+w+"\" height=\""+h+"\" data=\""+movie+"\"><param name=\"movie\" value=\""+movie+"\"><param name=\"quality\" value=\"high\"></object>");
}

function imgResize(img, iW,iH){
	var w = img.width;
	var h = img.height;
	if( w <= iW && h <= iH)
		return;
	if( (w/iW) > (h/iH) ){
		h = iH*(iW/w);
		w = iW;
	} else {
		w = iW*(iH/h);
		h = iH;
	}
	img.width = w;
	img.height = h;
}

function imgResize2(ImgD,iwidth,iheight){
			var flag=false;
			var image=new Image();
								
			image.src=ImgD.src;
				
			if(image.width>0 && image.height>0){
				
			flag=true;
				
				if(image.width/image.height>= iwidth/iheight){
				
					if(image.width>iwidth){ 
				
					ImgD.width=iwidth;
				
					ImgD.height=(image.height*iwidth)/image.width;
				
					}else{
				
					ImgD.width=image.width; 
				
					ImgD.height=image.height;
				 
					 }
				//ImgD.alt=image.width+"กม"+image.height;
				
				}
				
				else{
				
					if(image.height>iheight){ 
					
					ImgD.height=iheight;
					
					ImgD.width=(image.width*iheight)/image.height; 
					
					}else{
				
					ImgD.width=image.width; 
					
					ImgD.height=image.height;
					
					 }
				
				  //  ImgD.alt=image.width+"กม"+image.height;
				
				}
				
			}
				
} 
