// JavaScript Document

function trim(string){

    return string.replace(/^\s*|\s*$/g,"");

}

function v_url(string) 

{

	if(string.match(/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/)){

      return true;

  }else{

      return false;

  }

}



function v_domain(string) 

{

	if(string.match(/^[a-z]+[a-z0-9\.\-]+[a-z]{2,4}$/i)){

      return true;

  }else{

      return false;

  }

}

function v_email(string){
	var string = trim(string);
    if(string.match(/(^[a-z0-9]([\w\.\-]*)[a-z0-9]@[a-z0-9]([\w.\-]*)[a-z0-9]([.][a-z]{2,4})$)/i)){
        if(string.match(/[\.]{2,}/)){
          return false;
        }else{
          return true;
        }  
    }else{
        return false;
    }
}



function v_username(string){

		var string = trim(string);

		if(string.match(/^[a-z0-9][a-z0-9_]{4,23}[a-z0-9]$/i)){

	      return true;

	  }else{

	      return false;

	  }

}





function v_char(string){

   var string = trim(string);

	 if(string.match(/(.)+/)){

        return true;

    }else{

        return false;

    } 

}



function v_alphaNumeric(string){

   var string = trim(string);

	 if(string.match(/^[a-z0-9]+$/i)){

        return true;

    }else{

        return false;

    } 

}



function v_alphaNumericSpace(string){

   var string = trim(string);

	 if(string.match(/^[a-z0-9]+[\sa-z0-9]+[a-z0-9]+$/i)){

        return true;

    }else{

        return false;

    } 

}



function v_name(string){

   var string = trim(string);

	 if(string.match(/^[\w]+[\w\s\-\./']*[\w]+$/)){

        return true;

    }else{

        return false;

    } 

}

function v_address(string){

   var string = trim(string);

	 if(string.match(/^[\w]+[\w\s\-/']*[\w]+$/)){

        return true;

    }else{

        return false;

    } 

}


function v_usPostalCode(string){
    var string = trim(string);
	if(string.length == 5){
        return true;
    }else{
        return false;
    }
}


function v_postalCode(string){

    var string = trim(string);

	//if(string.match(/^[\w]+[\w\s]*[\w]+$/)){

	if(string.match(/(.)+/)){

        return true;

    }else{

        return false;

    }

}



function v_hour(string){

   if(string.match(/^[\w]+[\w\s\-\:]*[\w]+$/)){

        return true;

    }else{

        return false;

    } 



}

function v_phone(string){

    if(string.match(/^[\+]?[\d]+[\d\s\-]+[\d]+$/)){

        return true;

    }else{

        return false;

    }

}



function v_number(string){

    var string = trim(string);

		if(string.match(/^[\d]+$/)){

        return true;

    }else{

        return false;

    }

}



function v_float(string){

    var string = trim(string);

		var newV = parseFloat(string);

    if(newV == string){

        return true;

    }else{

        return false;

    }



}





function v_mobile(string){

   if(string.match(/^[\+]?[\d]+[\d\s]+[\d]+$/)){

        return true;

    }else{

        return false;

    }

}



function v_null(string){

   if(string==''){

        return false;

    }else{

        return true;

    }

}



function v_date(d,m,y)

{

	var yl=1990; 

	var ym=2050; 

	if (m<1 || m>12)

		return(false);

	if (d<1 || d>31) 

		return(false);

	if (y<yl || y>ym) 

		return(false);

	if (m==4 || m==6 || m==9 || m==11)

	if (d==31) 

		return(false);

	if (m==2)

	{

		var b=parseInt(y/4);

		if (isNaN(b))

			return(false);

		if (d>29)

			return(false);

		if (d==29 && ((y/4)!=parseInt(y/4))) 

			return(false);

	}

	 return(true);

}



function v_compareDate(date,month,year)

{

if(month<10)

	{

		month='0'+month;

	}

	if(date<10)

	{

		date='0'+date;

	}

	var tempDate=year+month+date;

	return tempDate;

}



function showHide(stringId){

    var showHideStat = document.getElementById(stringId).style.display;

    if(showHideStat == 'none'){

        document.getElementById(stringId).style.display = 'block';

    }else{

        document.getElementById(stringId).style.display = 'none';

    }

}



function popup(pageUrl){

    window.open(pageUrl,'mypopup','width=400 height=50');



}





function focusOn(filedName){



}





/* =========================================================================== */

/* =========================================================================== */

//Gets the browser specific XmlHttpRequest Object

function getXmlHttpRequestObject() {

    if (window.XMLHttpRequest) {

        return new XMLHttpRequest();

    } else if(window.ActiveXObject) {

        return new ActiveXObject("Microsoft.XMLHTTP");

    } else {

        alert("Your browser is not updated?");

    }

}

//Our XmlHttpRequest object to get the auto suggest

var searchReq = getXmlHttpRequestObject();

//Called from any event.

//Starts the AJAX request.

function makeRequest(custom_url,custom_function) {

    if (searchReq.readyState == 4 || searchReq.readyState == 0) {

         searchReq.open("GET", custom_url, true);

        searchReq.onreadystatechange = custom_function; 

        searchReq.send(null);

    }        

}

/* ========================================================================== */

function addOption(selectbox,text,value )

	{

		

		if (text)

		{			

			var optn = document.createElement("OPTION");

			optn.text = text;

			optn.value = value;

			selectbox.options.add(optn);

		}

	}

	

	function deleteOption(selectbox)

	{

		for (i = selectbox.length; i > 0 ; i--)

		{

			selectbox.remove(i);

		}

	}

//------Function Added By Prabhash-----Overlay//
function screenOverlay() {
	//alert('test')
  el = document.getElementById('overlayChild');
  if(el.style.display == 'none'){
	
	var defaultText = '<center><div class="main-box"> \
	<div class="top-heading-box">  \
	 <div class="close-btn"><a href="javascript:void(0);" onclick="screenOverlay()"><img src="images/close-ico.gif"    width="11" height="11" border="0" /></a> <a href="javascript:void(0);" onclick="screenOverlay()">Close</a></div> \
	</div> \
	<div class="content-box"> \
	<p class="box-text-bold"> Welcome to Indieonthemove.com! </p> \
	<p class="box-text">Our system has detected that you are using Internet Explorer version 8 or higher. For the best viewing results, please select "Compatibility Mode" in your browser window located to the right of your URL toolbar.</p> \
	<div class="btn-box"><a href="javascript:void(0);"><img src="images/ok-btn.gif"  onclick=\'screenOverlay()\' alt="" width="40" height="22" border="0" /></a></div> \
  </div> \
	<div class="clear"></div> \
</div></center>';

	$('overlayChild').update(defaultText);    
    ov.show();
  }else{
    ov.hide();
  }
}

/*
 * Simple Overlay using prototype-js
 * By Vinicius Baggio Fuentes <vinibaggio@gmail.com>
 *
 * Copyright 2009
 */

Overlay = Class.create({
	initialize: function(elem) {
		this._elem = $(elem);
		
		// Prepare the overlay
		if($('overlay') == null) {
			this._overlay = new Element('div', {id: 'overlay'});
		
			Object.extend(this._overlay.style, {
				zIndex: '1000',
				filter: 'alpha(opacity=60)',
				opacity: 0.6,
				display: 'none',
				top: '0px',
				left: '0px',
				position: 'absolute',
				backgroundColor: '#000'
			});
			
			
			$(document.body).insert(this._overlay);
		} else {
			this._overlay = $('overlay');
		}
		
		// NOTE: Bind click to the Overlay every time we instanciate a class
		// I do that so it is possible for us to have more than one 
		// overlay in a page.
		// ---------- this._hide.bindAsEventListener(this);
		// ---------- Event.observe(this._overlay, 'click', this._hide.bindAsEventListener(this));

		// Prepare the element
		//if(this._elem.getStyle('backgroundColor') == "transparent") {
			colour = "#fff";
		//} else {
		//	colour = this._elem.getStyle('backgroundColor');
		//}
		
		Object.extend(this._elem.style, {
			zIndex: '1100',
			backgroundColor: colour,
			position: 'absolute',
			top: '0px',
			left: '0px',
			border: '3px solid #474747',
			padding: '10px 10px 10px 10px',
			display: 'none'
		}); 
	},
	
	show: function() {
		// Fix IE
		$$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' });
		this._elem.select('select', 'object', 'embed','fieldset').each(function(node){node.style.visibility = 'visible'});

		// Position
		var pageSize = this.getPageSize();
		var screenWidth = document.all?document.body.clientWidth:window.innerWidth;
		var leftPos = this.scrollX() + (screenWidth / 2) - this._elem.getWidth() / 2;
		var topPos = this.scrollY() + 10;
				
		//this._overlay.setStyle({width: pageSize[0] + 'px', height: pageSize[1] + 'px'});
		this._overlay.setStyle({width: '100%', height: pageSize[1] + 'px'});
		this._elem.setStyle({top: topPos + 'px', left: leftPos + 'px'});
		
		// Disable scrolling
		document.body.style.overflow = 'hidden';

		this._overlay.show();
		this._elem.show();
	},
	
	hide: function() {
		this._hide();
	},
	
	_hide: function(evt) {
		this._elem.hide();
		this._overlay.hide();
		document.body.style.overflow = 'auto';
		// See the NOTE in constructor to understand why.
		// -------- Event.stopObserving(this._overlay, 'click', this._hide);
		$$('select', 'object', 'embed','fieldset').each(function(node){ node.style.visibility = 'visible' });
	},
	
	getPageSize: function() {

	     var xScroll, yScroll;

		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}

		var windowWidth, windowHeight;

		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	

		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}

		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}

		return [pageWidth,pageHeight];
	},
	
	scrollX: function () {return window.pageXOffset ? window.pageXOffset : document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft;},
	scrollY: function () {return window.pageYOffset ? window.pageYOffset : document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;}
	
});


function getCookie(c_name)
{
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
		{
		c_start=c_start + c_name.length+1;
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		return unescape(document.cookie.substring(c_start,c_end));
		}
	  }
	return "";
}

//-----Function to set cookie -----//
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

//-----Function to show compatibility message in IE>7 after checking cookie value -----//
function showBrowserMsg()
{	
	var browser=navigator.appName;
	if ((browser=="Microsoft Internet Explorer")&& document.documentMode==8)
	{	
		var message="";
	 	message=getCookie('message');
		if(message=="")
  	{	
      screenOverlay();
			message='yes';
			setCookie('message',message,1);
		}else{
		  //screenOverlay();
		}
	
	}else{
	   //screenOverlay();
	}

}

//------------------------------------//