function nueva(where){
   var nueva = window.open(where,"nueva",'fullscreen=no,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=370,height=380');
   nueva.moveTo(0,0);nueva.focus();
}

function openNewMap(){
	var map_id = document.getElementById("maphidden").value;
	window.open(map_id,'mywindow');
}
//---------------------------------------------------------------------------------------------------
//--------------------------------------- VENUE DIRECTORHY DETAIL -----------------------------------
//---------------------------------------------------------------------------------------------------

function ShowEachPic(which,id,venue){

		data='from=10&venue='+venue+'&id='+id+'&which='+which;
		postDataXml('ss_ajax.php', data, OkShowNextPic);
}

function ShowNextPic(position,venue,action){

		data='from=4&position='+position+'&venue='+venue+'&action='+action;
		postDataXml('ss_ajax.php', data, OkShowNextPic);
}


function OkShowNextPic(xml){
	
	options = xml.getElementsByTagName("option");
    var response = options[0].attributes.getNamedItem("response").nodeValue;
	
	if(response=="OK"){	
		var target = options[0].attributes.getNamedItem("target").nodeValue;
		var venue = options[0].attributes.getNamedItem("venue").nodeValue;
		var position = options[0].attributes.getNamedItem("position").nodeValue;
		var totalx = options[0].attributes.getNamedItem("total").nodeValue;
		var total = Number(totalx)+1;
		
		if(Number(position)==100){
			var postoshow = 1;
			var resetPag = 1;
		}else{
			var postoshow = Number(position)+2;
		}
		text='<img src="photos/venue_directory/large/'+target+'" width="640" height="300" border="0">';
		SetOption(text,"imagevenueDiv");
		
		if(resetPag != 1){
			text2= '<font color="#666666">'+postoshow+' / '+total+'</font><a href="javascript:void%200" onclick="ShowNextPic('+position+','+venue+',0)">';
			text2+='<img src="images/trans.gif" width="5" height="1" border="0"><img src="images/left_browse.gif" border="0" width="12" height="12"></a>';
			text2+='<a href="javascript:void%200" onclick="ShowNextPic('+position+','+venue+',1)">';
			text2+='<img src="images/trans.gif" width="2" height="1" border="0"><img src="images/right_browse.gif" border="0" width="12" height="12"></a>';
		}else{
			text2= ' <a href="javascript:void%200" onclick="ShowNextPic('+position+','+venue+',1)">'+postoshow+' / '+total;
			text2+='<img src="images/trans.gif" width="2" height="1" border="0"><img src="images/right_browse.gif" border="0" width="12" height="12"></a>';
		}
		SetOption(text2,"paginationDiv");
	}else{
	}
}
//---------------------------------------------------------------------------------------------------
//--------------------------------------- INDEX PAGE-------------------------------------------------
//---------------------------------------------------------------------------------------------------

function SearchCountry(type){
	ClearGogo(type);
	country = document.getElementById("search_country").value;
	if(country != 'null'){
		FillCategory(country);
		data="from=1&type="+type+"&country="+country;
		postDataXml('ss_ajax.php', data, OkSearchC);
	
	}else{//if they press null again
		FillCity();
		FillCategory(0);
	}
}

//---------------------------------------------------------------------------------------------------
function OkSearchC(xml){
	 options = xml.getElementsByTagName("option");
    response = options[0].attributes.getNamedItem("response").nodeValue;
	var type = options[0].attributes.getNamedItem("type").nodeValue;
	
	if(response=="OK"){	
		var type = options[0].attributes.getNamedItem("type").nodeValue;
		
		var text='<select style="height:21px;font-size:11px;width:100px;" name="search_city" id="search_city" onChange="SearchCity('+type+')"><option value="null">Select City</option>';
	
		for (loopIndex = 0; loopIndex < options.length; loopIndex++ )
		{
			var scity = options[loopIndex].attributes.getNamedItem("city").nodeValue;
			text+='<option value="'+scity+'">'+scity+'</option>'; 
		}
		
		text+='</select>';
		SetOption(text,"cityDiv");
		
	}else{
		//set city select empty
		text='<select style="height:21px;font-size:11px;width:100px;" name="search_city" id="search_city"><option value="null">Select City</option></select>';
		SetOption(text,"cityDiv");
		
		//set category select empty
		text2='<select style="height:21px;font-size:11px;width:100px;" name="search_category" id="search_category"><option value="null">Select Category</option></select>';
		SetOption(text2,"categoryDiv");
	}
	
}

//---------------------------------------------------------------------------------------------------
function SearchCity(type){
	ClearGogo(type);
	var city = document.getElementById("search_city").value;
	
	if(city != 'null'){	
		data='from=2&city='+city;
		postDataXml('ss_ajax.php', data, OkSearchCity);
	}else{
		FillCategory(0);
	}
}

//---------------------------------------------------------------------------------------------------
function OkSearchCity(xml){
	options = xml.getElementsByTagName("option");
    response = options[0].attributes.getNamedItem("response").nodeValue;
	
	if(response=='OK'){	
		
		
		var text='<select style="height:21px;font-size:11px;width:100px;" name="search_category" id="search_category"><option value="null">Select Category</option>';
	
		for (loopIndex = 0; loopIndex < options.length; loopIndex++ )
		{
			var scategory = options[loopIndex].attributes.getNamedItem("category").nodeValue;
			var sid = options[loopIndex].attributes.getNamedItem("id").nodeValue;
			text+='<option value="'+sid+'">'+scategory+'</option>'; 
		}
		
		text+='</select>';
		SetOption(text,"categoryDiv");
	}else{
		//set category select empty
		text='<select style="height:21px;font-size:11px;width:100px;" name="search_category" id="search_category"><option value="null">Select Category</option></select>';
		SetOption(text,"categoryDiv");
	}
}

//---------------------------------------------------------------------------------------------------
function FillCity(){
		data='from=7';
		postDataXml('ss_ajax.php', data, OkFillCity);
}

//---------------------------------------------------------------------------------------------------
function OkFillCity(xml){
	options = xml.getElementsByTagName("option");
    response = options[0].attributes.getNamedItem("response").nodeValue;
	
	if(response=='OK'){	
		text='<select style="height:21px;font-size:11px; width:100px;" name="search_city" id="search_city" onChange="SearchCity(0)">';
		text+='<option value="null">Select City</option>';
		
		for (loopIndex = 0; loopIndex < options.length; loopIndex++ )
		{
			var cityfull = options[loopIndex].attributes.getNamedItem("cityfull").nodeValue;
			text+='<option value="'+cityfull+'">'+cityfull+'</option>'; 
		}
		text+='</select>';
		SetOption(text,"cityDiv");
	
	}else{
		text='<select style="height:21px;font-size:11px;width:100px;" name="search_city" id="search_city">';
		text+='<option value="null">Select City</option></select>';
		SetOption(text,"cityDiv");
	}
}

//---------------------------------------------------------------------------------------------------
function FillCategory(country){
	if(country==0){
		data='from=8';
	}else{
		data='from=9&country='+country;
	}
	postDataXml('ss_ajax.php', data, OkFillCategory);
}

//---------------------------------------------------------------------------------------------------
function OkFillCategory(xml){
	options = xml.getElementsByTagName("option");
    response = options[0].attributes.getNamedItem("response").nodeValue;
	
	if(response=='OK'){	
		text='<select style="height:21px;font-size:11px; width:100px;" name="search_category" id="search_category" onChange="ClearGogo(0)">';
		text+='<option value="null">Select Category</option>';
		
		for (loopIndex = 0; loopIndex < options.length; loopIndex++ )
		{
			var catidfull = options[loopIndex].attributes.getNamedItem("catidfull").nodeValue;
			var catnamefull = options[loopIndex].attributes.getNamedItem("catnamefull").nodeValue;
			
			text+='<option value="'+catidfull+'">'+catnamefull+'</option>'; 
		}
		text+='</select>';
		SetOption(text,"categoryDiv");
	
	}else{
		text='<select style="height:21px;font-size:11px;width:100px;" name="search_category" id="search_category">';
		text+='<option value="null">Select Category</option></select>';
		SetOption(text,"categoryDiv");
	}
}


//---------------------------------------------------------------------------------------------------
function CheckSearchIndex(type){
	var con = document.getElementById("search_country").value;
	var cit = document.getElementById("search_city").value;
	var cat = document.getElementById("search_category").value;
	var gogo;
	
	
	if(con=='null'){
		if(cit=='null'){
			if(cat=='null'){
				gogo=false;
				text='Select an option first <img src="images/trans.gif" height="20" width="1">';
				SetOption(text,"gogoDiv");
			}else{
				gogo=true;
			}
		}
	}
	return gogo;
}
//---------------------------------------------------------------------------------------------------
function ClearGogo(type){
	
	if(type==0){
		text='<input type="image" src="images/go0.gif" width="60" height="20">';
		t2='<img src="images/trans.gif" width="1" height="10" border="0">';
		SetOption(t2,"gogo2Div");
		SetOption(text,"gogoDiv");
	}else{
		text='<input type="image" src="images/go0.gif" width="60" height="20">';
		SetOption(text,"gogoDiv");
	}
}

//---------------------------------------------------------------------------------------------------
function CheckSearchIndex0(){
	var con = document.getElementById("search_country").value;
	var cit = document.getElementById("search_city").value;
	var cat = document.getElementById("search_category").value;
	var gogo;
	
	
	if(con=='null'){
		if(cit=='null'){
			if(cat=='null'){
				gogo=false;
				text='Select an option first <img src="images/trans.gif" height="12" width="1">';
				SetOption(text,"gogo2Div");
				SetOption("","gogoDiv");
			}else{
				gogo=true;
			}
		}
	}
	return gogo;
}

//---------------------------------------------------------------------------------------------------
function NotSponsored(num){
	text='<b>No further details available</b>';
	SetOption(text,"detail"+num+"Div");

}

//---------------------------------------------------------------------------------------------------
function NotSponsored(num){
	AddCounter(num,0);
	text='<b>No further details available</b>';
	SetOption(text,"detail"+num+"Div");

}
//---------------------------------------------------------------------------------------------------
function AddCounter(venue,state){
	data='from=6&venue='+venue+'&state='+state;
	postDataXml('ss_ajax.php', data, OkAddCounter);
}

function OkAddCounter(xml){
	
}

function Newsletter(){
 	var emailx = document.getElementById("email2");
 	if(ValidateEmail(emailx)){
	
		ready=emailx.value;
		data='from=3&mailx='+ready;
		postDataXml('ss_ajax.php', data, OkNewsletter);
	
	}
  
}

function OkNewsletter(xml){
	options = xml.getElementsByTagName("option");
    var response = options[0].attributes.getNamedItem("response").nodeValue;
	
	if(response=='OK'){	
		text="Thank you, your address has been received.";
		SetOption(text,"newsletterDiv");
		document.getElementById("email2").value="";
	}
	else{
		text="Sorry, please try again";
		SetOption(text,"newsletterDiv");
		document.getElementById("email2").value="";
	}
}
//---------------------------------------------------------------------------------------------------
function ValidateEmail(mail){
	var emailID = mail;
	text="Please enter your email address in the field below";
	
	if ((emailID.value==null)||(emailID.value=="")){
		SetOption(text,"newsletterDiv");
		return false
	}
	if (echeck(emailID.value)==false){
		SetOption(text,"newsletterDiv");
		return false
	}
	return true
}

//---------------------------------------------------------------------------------------------------
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		text="Please enter a valid email address";
		
		if (str.indexOf(at)==-1){
		   SetOption(text,"newsletterDiv");
		   return false }

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		    SetOption(text,"newsletterDiv");
		   return false }

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    SetOption(text,"newsletterDiv");
		    return false }

		 if (str.indexOf(at,(lat+1))!=-1){
		    SetOption(text,"newsletterDiv");
		    return false }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		     SetOption(text,"newsletterDiv");
		    return false }

		 if (str.indexOf(dot,(lat+2))==-1){
		     SetOption(text,"newsletterDiv");
		    return false }
		
		 if (str.indexOf(" ")!=-1){
		     SetOption(text,"newsletterDiv");
		    return false }

 		 return true					
}

//---------------------------------------------------------------------------------------------------
//--------------------------------         POP UP      --------------------------------------------
//---------------------------------------------------------------------------------------------------
function ShowExtraVenueInfo(venue_id,jov_id){
		
	data='from=5&venue='+venue_id+'&jov='+jov_id;
	postDataXml('ss_ajax.php', data, OkShowExtraVenueInfo);	
}

function OkShowExtraVenueInfo(xml){
	
	options = xml.getElementsByTagName("option");
    var response = options[0].attributes.getNamedItem("response").nodeValue;
	
	if(response=='OK'){	
		SetOption("","venuedisplayDiv");//reset empy message
		
		var city = options[0].attributes.getNamedItem("city").nodeValue;
		var time = options[0].attributes.getNamedItem("time").nodeValue;
		var id = options[0].attributes.getNamedItem("id").nodeValue;
		var venue0 = options[0].attributes.getNamedItem("venue").nodeValue;
		var address0 = options[0].attributes.getNamedItem("address").nodeValue;
		var conname0 = options[0].attributes.getNamedItem("conname").nodeValue;
		var conphone = options[0].attributes.getNamedItem("conphone").nodeValue;
		var conemail = options[0].attributes.getNamedItem("conemail").nodeValue;
		var room0 = options[0].attributes.getNamedItem("room").nodeValue;
		var capacity = options[0].attributes.getNamedItem("capacity").nodeValue;
		var layout = options[0].attributes.getNamedItem("layout").nodeValue;
		var delegates0 = options[0].attributes.getNamedItem("delegates").nodeValue;
		var rate0 = options[0].attributes.getNamedItem("rate").nodeValue;
		var caterer0 = options[0].attributes.getNamedItem("caterer").nodeValue;
		var supplier0 = options[0].attributes.getNamedItem("supplier").nodeValue;
		var postcode = options[0].attributes.getNamedItem("postcode").nodeValue;
		
		var venue = PrepareToShow(venue0);
		var address00 = PrepareToShow(address0);
		var address = DisplayText(address00);
		var conname = PrepareToShow(conname0);
		var room = PrepareToShow(room0);
		var caterer = PrepareToShow(caterer0);
		var supplier = PrepareToShow(supplier0);
		var delegates = PrepareToShow(delegates0);
		var rate = PrepareToShow(rate0);
		
		var text='<table class="ewTablepop" width="330"><tr>';
		text+='<td class="popHeader">Venue</td><td width="200">'+venue+'</td><td><a href="javscript:void%200" onclick="ClosePopUp('+id+')"><b>X</b></a></td></tr><tr>';
		text+='<td class="popHeader">Address</td><td colspan="2" height="38" valign="top">'+address+postcode+'</td></tr><tr>';
		text+='<td class="popHeader">Room</td><td colspan="2">'+room+'</td></tr><tr>';
		text+='<td class="popHeader">Delegates</td><td colspan="2">'+delegates+'</td></tr><tr>';
		text+='<td class="popHeader">Layout</td><td colspan="2">'+layout+'</td></tr><tr>';
		text+='<td class="popHeader">Capacity</td><td colspan="2">'+capacity+'</td></tr><tr>';
		text+='<td class="popHeader">Sixstar rate</td><td colspan="2">'+rate+'</td></tr>';
		text+='<td class="popHeader">Catereer</td><td colspan="2">'+caterer+'</td></tr><tr>';
		text+='<td class="popHeader">AV supplier</td><td colspan="2">'+supplier+'</td></tr><tr>';
		text+='<td class="popHeader">Contact name</td><td colspan="2">'+conname+'</td></tr><tr>';
		text+='<td class="popHeader">Contact phone</td><td colspan="2">'+conphone+'</td></tr><tr>';
		text+='<td class="popHeader">Contact email</td><td colspan="2">'+conemail+'</td>';
		//text+='<td class="popHeader">Time</td><td colspan="2">'+time+'</td></tr><tr>';
		//text+='<td class="popHeader">City</td><td>'+city+'</td></tr><tr>';
		text+='</tr></table>';
		
		//SetOption(text,"venuedisplayDiv");
		
		var artworkDiv = document.getElementById("nextvenue"+id+"Div");
		//var Xpos= findPosX(artworkDiv);
		var Ypos= findPosY(artworkDiv);
		
					var dialog = document.createElement("div");
					dialog.style.position = "absolute";
					//dialog.style.left =  (Xpos-355) +"px";
					dialog.style.top = (Ypos - 285) + "px";
					dialog.style.width = "350px";
					dialog.style.height = "314px";
					dialog.style.zIndex = 2;
					dialog.innerHTML = text;
               		SetBackground(dialog.style,'images/backtext');//find if explorer version is older than 7
					artworkDiv.appendChild(dialog);
	
	}else{SetOption("No venue information available","venuedisplayDiv");
	}
}

function ClosePopUp(id){
	SetOption("","nextvenue"+id+"Div");
}

function PrepareToShow(str){
	str=str.replace(/\\'/g,'\'');
	str=str.replace(/\\"/g,'"');
	str=str.replace(/\\\\/g,'\\');
	str=str.replace(/\\0/g,'\0');
	str=str.replace(/a1a/g,"<");
	str=str.replace(/b1b/g,">");
	return str;
}

function findPosX(obj){
    var curleft = 0;
    if(obj.offsetParent)
        while(1) {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj){
    var curtop = 0;
    if(obj.offsetParent)
        while(1){
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}

function DisplayText(text){
		var cc= text.split("||");
		var res='';
		for(var i = 0; i < cc.length; i++){
			res+=cc[i]+'<br>'; 
		}
		res=res.replace(/<br><br>/g,'<br />');
	return res;
}

//.................................... ............................................. ..................................................
//.................................... handle png pictures for help display          ..................................................

function SetBackground(objectx,path) {	
	if (pngAlpha) {
        objectx.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+path+".png', sizingMethod='scale')";
	} else if (pngNormal) {
		objectx.backgroundImage = 'url('+path+'.png)';
	} else {
		objectx.backgroundImage = 'url('+path+'.gif)';
	}
}
//.................................... ............................................. ..................................................

// if IE5.5+ on win32, then display PNGs with AlphaImageLoader
if ((browser.isIE55 || browser.isIE6) && browser.isWin32) {
	var pngAlpha = true;
	var strExt = ".png";

} else if ((browser.isIE6up) ||(browser.isGecko) || (browser.isIE5up && browser.isMac) || (browser.isOpera && browser.isWin && browser.versionMajor >= 6) || (browser.isOpera && browser.isUnix && browser.versionMajor >= 6) || (browser.isOpera && browser.isMac && browser.versionMajor >= 5) || (browser.isOmniweb && browser.versionMinor >= 3.1) || (browser.isIcab && browser.versionMinor >= 1.9) || (browser.isWebtv) || (browser.isDreamcast)) {
	var pngNormal = true;
	var strExt = ".png";
	// otherwise, we use plain old GIFs
} else {
	var strExt = ".gif";
}

var ns = (document.all)?false:true;
var browserVersion = parseFloat(navigator.appVersion );



//---------------------------------------------------------------------------------------------------
//--------------------------------   PROVIDER AREA / EXPORT  ----------------------------------------
//---------------------------------------------------------------------------------------------------
function ExportXls(choice, client,contact,commision){
	var text='&nbsp;&nbsp;|&nbsp;&nbsp;File created (';
	
	switch(choice){
	case 3: var year = 0;
			var fmonth = 0;
			text+= 'SS_CA_All.xls';
			break;
	case 2:	var year = document.getElementById("yearx").value;
			var fmonth = 0;	
			text+= 'SS_CA_'+year+'.xls';
			break;
	case 1:	var year = document.getElementById("fyear").value;
			var fmonth = document.getElementById("fmonth").value;
			text+= 'SS_CA_'+year+'-'+fmonth+'.xls';
			break;
	}
	data='export_xls.php?choice='+choice+'&x1='+client+'&x2='+contact+'&x3='+commision+'&x4='+year+'&x5='+fmonth;
	window.open(data);
	text+=')';
	SetOption(text,"showexportDiv");
}


//---------------------------------------------------------------------------------------------------
//--------------------------------         printer       --------------------------------------------
//---------------------------------------------------------------------------------------------------
function SetOption(text, targetDiv){
      var target= document.getElementById(targetDiv); 
       target.innerHTML = text;
}


//---------------------------------------------------------------------------------------------------
//---------------------------------------- SENDER AJAX HEART ----------------------------------------
//---------------------------------------------------------------------------------------------------
function postDataXml(url, data, callback)
{ 
  var XMLHttpRequestObject = false; 

  if (window.XMLHttpRequest) {
    XMLHttpRequestObject = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    XMLHttpRequestObject = new 
     ActiveXObject("Microsoft.XMLHTTP");
  }

  if(XMLHttpRequestObject) {
    XMLHttpRequestObject.open("POST", url); 
    XMLHttpRequestObject.setRequestHeader('Content-Type', 
      'application/x-www-form-urlencoded'); 

    XMLHttpRequestObject.onreadystatechange = function() 
    { 
      if (XMLHttpRequestObject.readyState == 4 && 
        XMLHttpRequestObject.status == 200) {
          callback(XMLHttpRequestObject.responseXML); 
          delete XMLHttpRequestObject;
          XMLHttpRequestObject = null;
      } 
    }

    XMLHttpRequestObject.send(data); 
  }
}


function SetFrame(){
   self.moveTo(0,0);
   self.resizeTo(screen.availWidth,screen.availHeight);
 } 
