function QuickContactShowCapcha(){
	document.getElementById('caphcha-1').style.display = 'block';
	document.getElementById('caphcha-2').style.display = 'block';
}
function filterPhoneKeys(e){
	e = e || window.event;
	var chara = e.keyCode || e.charCode;
	ok = false;
	ok_values = new Array('96','97','98','99','100','101','102','103','104','105','48','49','50','51','52','53','54','55','56','57','9','46','32','107','109','16','187','189','36','35');
	for(i=0;i<ok_values.length;i++){
		if(ok_values[i]==chara){
			ok = true;
		}
	}
	if(ok){
		return true;
	}else{
		return false;
	}
}

function str_replace(search, replace, subject) {
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
    // *     returns 2: 'hemmo, mars'
    var s = subject;
    var ra = r instanceof Array, sa = s instanceof Array;
    var f = [].concat(search);
    var r = [].concat(replace);
    var i = (s = [].concat(s)).length;
    var j = 0;
    
    while (j = 0, i--) {
        if (s[i]) {
            while (s[i] = (s[i]+'').split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
        }
    }
 
    return sa ? s : s[0];
}

function HTMLString(str){
	str = str_replace('\n','<br>',str);
	//str = str_replace('"','&quot;',str);
	return str;
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}
function ChangeBoxText(obj, str){
	divs = obj.getElementsByTagName('div');
	for(i=0;i<divs.length;i++){
		if(divs[i].className=='center'){
			divs[i].innerHTML = str;
		}
	}
}
function UpdateUserNameSpans(name){
	spans = document.getElementsByTagName('span');
	for(i=0;i<spans.length;i++){
		if(spans[i].className=='UserName'){
			spans[i].innerHTML = name;
		}
	}
}

		//tableAnimation.size(contentLayer, contentLayer.offsetWidth, newTable.offsetHeight+20, 300, 1, 0, 'SwitchTable3()');
		//xOpacity(CoverObj(newTable), 1);
		//tabAnimation.opacity(TabCoverObj(tabContent), 1, 500, 1, 0, 'SwitchTab2()');

var Animationobj = new xAnimation(40);
function XAnimationShow(objId){
	obj = document.getElementById(objId);
	if(obj.style.display=='none' || obj.className.indexOf('hidden')>0){
		// Create Cover
		obj.style.position = 'absolute';
		obj.style.visibility = 'hidden';
		obj.style.display = 'block';
		height = obj.offsetHeight;
		obj.style.display = 'none';
		obj.style.visibility = 'visible';
		obj.style.position = 'relative';
		cover = document.createElement('div');
		cover.style.position = 'absolute';
		cover.style.top = '0px';
		cover.style.left = '0px';
		cover.style.height = height + 'px';
		cover.style.width = 100 + '%';
		cover.style.background = 'white';
		cover.className = 'Animation-Cover';
		cover.setAttribute('class','Animation-Cover');
		obj.appendChild(cover);
		// Resize Object
		obj.style.height = '0px';
		obj.style.overflow = 'hidden';
		obj.style.display = 'block';
		Animationobj.size(obj, obj.offsetWidth, height, 600, 1, 0, 'XAnimationShow2("'+objId+'")');
	}
}
function XAnimationShow2(objId){
	obj = document.getElementById(objId);
	divs = obj.getElementsByTagName('div');
	for(i=0;i<divs.length;i++){
		if(divs[i].className=='Animation-Cover'){
			cover = divs[i];
			break;
		}
	}
	Animationobj.opacity(cover, 0, 1000, 1, 0, '');
}

function getStyle(el, styleProp, styleProp2){
	if (el.currentStyle){
		var y = el.currentStyle[styleProp];
		if(!y){ y = el.currentStyle[styleProp2]; }
	}else{ 
			if (window.getComputedStyle){
			var y = document.defaultView.getComputedStyle(el, null).getPropertyValue(styleProp);
			if(!y){ y = document.defaultView.getComputedStyle(el, null).getPropertyValue(styleProp2);}
		}
	}
	return y;
}

//document.onmousemove = mouseMove;

function mouseMove(ev){
	ev = ev || window.event;
	mousePos = mouseCoords(ev);
}

function mouseCoords(ev){
	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}
	return {
		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
		y:ev.clientY + document.body.scrollTop  - document.body.clientTop
	};
}


function checkEmailAddress(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		 if (str.indexOf(" ")!=-1){
		    return false
		 }
 		 return true					
	}
	
function SubmitQuestion(){
	theform = document.getElementById('quick-contact');
	alertobj = document.getElementById('have-a-question-alert');
	alright = true;
	if(theform.name.value=='' && alright){
		alright = false;
		theform.name.focus();
		alertobj.innerHTML = dic_fill_name;
		alertobj.style.display = 'block';
	}
	if(theform.qphone.value=='' && alright){
		alright = false;
		theform.qphone.focus();
		alertobj.innerHTML = dic_invalid_email;
		alertobj.style.display = 'block';
	}
	if(alright){
		theform.submit();
		alertobj.style.color = '#737373';
		alertobj.innerHTML = dic_sending_question;
		alertobj.style.display = 'block';
	}
}
function QuestionWrongCode(){
		theform = document.getElementById('quick-contact');
		alertobj = document.getElementById('have-a-question-alert');
		sendbtn = document.getElementById('question-submit-button');
		alertobj.style.color = 'red';
		alertobj.innerHTML = dic_incorrect_code;
		theform.securityImageValue.value = '';
		theform.securityImageValue.focus();
}
function QuestionSuccess(){
		theform = document.getElementById('quick-contact');
		alertobj = document.getElementById('have-a-question-alert');
		sendbtn = document.getElementById('question-submit-button');
		
		items = theform.getElementsByTagName('div');
		for(i=0;i<items.length;i++){
			if(items[i].className=='listitem' || items[i].className=='listitem hidden'){
				items[i].style.display = 'none';
			}
		}
		alertobj.style.color = '#333333';
		alertobj.innerHTML = dic_question_sent;
		alertobj.style.display = 'block';
		sendbtn.style.display = 'none';
}
