function checkFrame(strURL) {
	strURL = replace(replace(replace(replace(strURL,'?','$'),'=','@'),'&','*'),'http://www.ownvilla.com/','');
	if (self == top) {
	  	location.href = '/?sURL=' + strURL;
	}
}

function checkTopValue(strItem) {
	return (typeof strItem != 'undefined'&&strItem !='')?true:false;
}

function replace(string,text,by) {
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

function changeClass(obj, strStr) {
   	var strSrc = obj.className;
		
	if(strSrc.indexOf('-off') != -1) {
  		rExp = /-off/gi;
   		obj.className = strSrc.replace(rExp,'-on');
	}
	else {
	   rExp = /-on/gi;
       obj.className = strSrc.replace(rExp,'-off');
	}
}

function labelHover(obj, bHover) {
	if (bHover == true) {
		obj.style.textDecoration = 'underline';
		obj.title = 'Click to select'
	}
	else {
		obj.style.textDecoration = 'none';
	}
}

var zoomfactor=0.05 //Enter factor (0.05=5%)
		
function zoomhelper(){
	var intZoomMax
	
	if(window.screen.width < 1024) { 
		intZoomMax = 580; 
	}
	else {
		if(window.screen.width == 1024) { 
			intZoomMax = 600;
		}
		else {
		  intZoomMax = (window.screen.width - 420);
		}
	}
	
	if (parseInt(whatcache.style.width)>10&&parseInt(whatcache.style.height)>10){
	   if (parseInt(whatcache.style.width) <= intZoomMax) {
	       whatcache.style.width=parseInt(whatcache.style.width)+parseInt(whatcache.style.width)*zoomfactor*prefix;
	       whatcache.style.height=parseInt(whatcache.style.height)+parseInt(whatcache.style.height)*zoomfactor*prefix;
	   }
	}
}

function zoom(originalW, originalH, what, state){
	if (!document.all&&!document.getElementById)
	return
	whatcache=eval("document.images."+what);
	prefix=(state=="in")? 1 : -1;
	if (whatcache.style.width==""||state=="restore"){
	whatcache.style.width=originalW;
	whatcache.style.height=originalH;
	if (state=="restore")
		return
	}
	else{
		zoomhelper();
	}
	beginzoom=setInterval("zoomhelper()",100);
}

function clearzoom(){
	if (window.beginzoom) { clearInterval(beginzoom); }
}

function setSelectbox(strValue, objSelectBox) {
     try {
         if(strValue!='') {
            for(var intIndex=0;intIndex<objSelectBox.options.length;intIndex++) {
               objSelectBox.options[intIndex].selected = (objSelectBox.options[intIndex].value == strValue)?true:false;
            }
		 }
	 }
	 catch(err) {};
}

function ClearZero(objText) {
	if (objText.value == '0')
	{
		objText.value = '';
	}
	else
	{
	if (objText.value == '')
		{
		objText.value = '0';
		}
	}
}

function CheckNumeric(objText) {
	if (isNaN(objText.value)) {
			objText.value = '0';
    }
}