﻿function MM_openBrWindow(theURL,winName,features) {window.open(theURL,winName,features);}
function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
    if ((obj=MM_findObj(args[i]))!=null) {
        v=args[i+2];
        if (obj.style) {
            obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; 
    }
    obj.visibility=v; 
  }
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

String.prototype.trim = function(){return this.replace(/(^\s*)|(\s*$)/g, "");}

function checkEmail(checkThisEmail){
var myEMailIsValid = true;
var myAtSymbolAt = checkThisEmail.indexOf('@');
var myLastDotAt = checkThisEmail.lastIndexOf('.');
var mySpaceAt = checkThisEmail.indexOf(' ');
var myLength = checkThisEmail.length;
if (myAtSymbolAt < 1 ){myEMailIsValid = false}
if (myLastDotAt < myAtSymbolAt) {myEMailIsValid = false}
if (myLength - myLastDotAt <= 2){myEMailIsValid = false}
if (mySpaceAt != -1) {myEMailIsValid = false}
return myEMailIsValid
}

function emptyField(textObj){
	if (textObj.value.length == 0) return true;
	for (var i=0; i<textObj.value.length; i++) {
		var ch = textObj.value.charAt(i);
		if (ch != ' ' && ch != '\t') return false;	
	}
	return true;	
}




function CheckFields_contact(obj,site_url){
	var doc=window.document;
	if (obj.firstName.value==''){alert('Please fill in the "First name"'); obj.firstName.focus(); return false;}
	if (obj.lastName.value==''){ alert('Please fill in the "Last name"'); obj.lastName.focus();return false;}
	if (obj.email.value==''){alert('Please fill in the "Email"');obj.email.focus();return false;}
    if (obj.email.value!=''  && !checkEmail(obj.email.value)){alert('The "email" address is not in the correct format');obj.email.select();return false;}
    if (obj.phone.value==''){alert('Please fill in the "Phone"'); obj.phone.focus(); return false;}
    if (obj.captchacode.value==''){alert('Please fill in the "Code"');obj.captchacode.focus();return false;}
    return true;
}




function check_fields_subscription(site_url) {	
	if (document.getElementById('subscription_email').value == "" ){
	   alert('Please fill in the "Email"');
	   document.getElementById('subscription_email').focus();
	return false;}
    if (!checkEmail(document.getElementById('subscription_email').value)){
	   alert('The "email" address is not in the correct format');
	   document.getElementById('subscription_email').focus();
	return false;}
	window.document.subscriptionForm.action=site_url+"subscription/subscription_thanks.asp";
	window.document.subscriptionForm.submit();
	return false;					
}

function check_fields_unSubscription(site_url) {		
	if (document.getElementById('subscription_email').value == "" ){
	   alert('Please fill in the "Email"');
	   document.getElementById('subscription_email').focus();
	return false;}
    if (!checkEmail(document.getElementById('subscription_email').value)){
	   alert('The "email" address is not in the correct format')
	   document.getElementById('subscription_email').focus();
	return false;}
	if (confirm("You really want to unsubscribe?")){
	    window.document.subscriptionForm.action=site_url+"subscription/unSubscription.asp";
	    window.document.subscriptionForm.submit();
	}
	return false;					
}



function action_picture(picFile,picDesc){
   if (document.getElementById('picture_Big') && picFile!=''){
      if (document.all){
           document.getElementById('picture_Big').style.filter="blendTrans(duration=1)";
           document.getElementById('picture_Big').filters.blendTrans.Apply();
       }
       document.getElementById('picture_Big').style.visibility='hidden';
	   document.getElementById('picture_Big').src = picFile;
	   document.getElementById('picture_Big').style.visibility='visible';		
       if (document.all){
           document.getElementById('picture_Big').filters.blendTrans.Play();
        }
   }
   document.getElementById("divTitle").innerText=unescape(picDesc);
   return false;
}
function action_picture_before(picFile,picDesc){
   if (document.getElementById('picture_Big_before') && picFile!=''){
      if (document.all){
           document.getElementById('picture_Big_before').style.filter="blendTrans(duration=1)";
           document.getElementById('picture_Big_before').filters.blendTrans.Apply();
       }
       document.getElementById('picture_Big_before').style.visibility='hidden';
	   document.getElementById('picture_Big_before').src = picFile;
	   document.getElementById('picture_Big_before').style.visibility='visible';		
       if (document.all){
           document.getElementById('picture_Big_before').filters.blendTrans.Play();
        }
   }
   document.getElementById("divTitle_before").innerText=unescape(picDesc);
   return false;
}


function onclick_picture(picFile,picNumber){
   if (document.images['picture_Big'] && picFile!=''){
      if (document.all){
           document.images['picture_Big'].style.filter="blendTrans(duration=1)";
           document.images['picture_Big'].filters.blendTrans.Apply();
       }
       document.images['picture_Big'].style.visibility='hidden';
	   document.images['picture_Big'].src = picFile;
	   document.images['picture_Big'].style.visibility='visible';		
       if (document.all){
           document.images['picture_Big'].filters.blendTrans.Play();
        }
       if (picNumber!=''){
           changeHTML('SlideImageId',picNumber);
       }
   }
   return false;
}

function changeHTML(spanId,code){
    var element = document.getElementById(spanId);
	if(element) {
	    element.innerHTML = unescape(code);
	}
}
function gallery_picture(picFile){
   if (document.getElementById('picture_Big') && picFile!=''){
      if (document.all){
           document.getElementById('picture_Big').style.filter="blendTrans(duration=1)";
           document.getElementById('picture_Big').filters.blendTrans.Apply();
       }
       document.getElementById('picture_Big').style.visibility='hidden';
	   document.getElementById('picture_Big').src = picFile;
	   document.getElementById('picture_Big').style.visibility='visible';		
       if (document.all){
           document.getElementById('picture_Big').filters.blendTrans.Play();
        }
   }
   return false;
}
