function showDiv(theDiv){
	document.getElementById(theDiv).style.display = "block";
}

function hideDiv(theDiv){
	document.getElementById(theDiv).style.display = "none";
}
function border_over(id){
	document.getElementById(id).style.border = "1px solid #FFCC66";
	//document.getElementById(id).style.filter = "Alpha(Opacity=70)";
}
function border_out(id){
	document.getElementById(id).style.border = "1px solid #CC6600";
	//document.getElementById(id).style.filter = "Alpha(Opacity=100)";
}
function adjustSize() {
	//alert('*');
	/*if (screen.width > 1024){;
		window.moveTo(0,0);
		window.resizeTo(1024,768);
		
	}*/
	
}
/**********************************
// valid contact form
**********************************/

function valid_contactForm(){

	 var errors = '';

	 var errorsHeadlines='The required information is incomplete or contains errors:\n\n';
	 i=0
	 if (document.conect.name.value==""){
		i++
		errors +=i+'.   The "name" field is empty \n'
	 }
	 if ( (document.conect.phone.value=="") && (document.conect.email.value=="")  && (document.conect.fax.value=="") ) {
		i++
		errors +=i+'.   Please fill at least one of the fields: "Phone", "fax" or "E-mail"   \n'
	 }
	 if (document.conect.email.value !=""){
		p = document.conect.email.value.indexOf('@') 
		if ((p < 1)  || (document.conect.email.value.length < 3)){
			i++
			errors +=i+'.   Field "E-mail" is not valid\n'
		}
	}
	if (errors != '') { alert( errorsHeadlines+errors ) }
	document.returnValue = (errors == '');	
}

/**********************************
//  popup window to print
**********************************/
var myWin=0;
function popup_win(URLStr, width, height){
   y = screen.availHeight/2 - height/2;
   x = screen.availWidth/2 - width/2; 

	if(myWin) {
		if(!myWin.closed){
			myWin.close();
		}
	}
  	myWin = open(URLStr, 'myWin', 'status=yes,scrollbars=yes,resizable=yes,width='+width+',height='+height+',left='+x+', top='+y+',screenX='+x+',screenY='+y+'');
	
}
/******************************************************************
   function to create an XMLHttpClient in a cross-browser manner   
*******************************************************************/
function initXMLHttpClient() {   
	var xmlhttp;   
	try {   
     	// Mozilla / Safari / IE7   
     	xmlhttp = new XMLHttpRequest();   
  	} catch (e) {   
    // IE   
    var XMLHTTP_IDS = new Array('MSXML2.XMLHTTP.5.0',   
								'MSXML2.XMLHTTP.4.0',   
								'MSXML2.XMLHTTP.3.0',   
								'MSXML2.XMLHTTP',   
								'Microsoft.XMLHTTP' );   
     	var success = false;   
     	for (var i=0;i < XMLHTTP_IDS.length && !success; i++) {   
       		try {   
       			xmlhttp = new ActiveXObject(XMLHTTP_IDS[i]);   
       			success = true;   
      		} catch (e) {}   
     	}   
		if (!success) {   
			throw new Error('Unable to create XMLHttpRequest.');   
		}   
	}   
   	return xmlhttp;   
}   
/****************************************************************/

var callback = function(){
}

// פונקציה בסיסית בשיטת הגט
function processAjax(objID, serverPage, func) { 
	var obj = document.getElementById(objID);
	var req = initXMLHttpClient();
	callback=func;
	req.onreadystatechange = function() {
		if (req.readyState == 2) {
			obj.innerHTML = "Loading . . .";
		}
		if (req.readyState == 4) {
			if(req.status == 200){
				obj.innerHTML = req.responseText;
				callback();
			}else{
				alert('Loading Error: ['+req.status+'] '+req.statusText);
			}
		}
	}
	req.open('GET', serverPage, true);
 	req.send(null);
}

function playMusic(serverPage) { 
	var objF = document.getElementById('flashDiv');
	var objC = document.getElementById('coverDiv');
	var req = initXMLHttpClient();
	
	req.onreadystatechange = function() {
		if (req.readyState == 2) {
			objC.style.zIndex="200";
			objC.style.visibilty="visible"
			objF.style.zIndex="100";
			objF.style.visibilty="hidden                              "
		}
		if (req.readyState == 4) {
			if(req.status == 200){
				objF.innerHTML = req.responseText;
			}else{
				alert('Loading Error: ['+req.status+'] '+req.statusText);
			}
		}
	}
	req.open('GET', serverPage, true);
 	req.send(null);
}
// =========== subs =====================
function show_sub(i){
	url = 'subs_pop.php?idtop_sub='+i;
	document.getElementById('listleft').style.display = "block";
	processAjax('listleft', url,  callback);
}
function close_sub(){
	document.getElementById('listleft').innerHTML = "";
	document.getElementById('listleft').style.display = "none";
}
function show_bigpic(i){	
	url = 'bigpic.php?id_img='+i;
	document.getElementById('bigpic').style.visibility = "visible";
	processAjax('bigpic', url,  callback)
}
function close_bigpic(){	
	document.getElementById('bigpic').style.visibility = "hidden";
	document.getElementById('bigpic').innerHTML = "";
}

// =========== וידאו =====================
function showvideo(url){
	processAjax('vidiv', url,  callback)
}
function closevideo(){
	document.getElementById('vidiv').innerHTML = "";
}
// =======================================
