function getlist(id) {

var text = 'main.php?item=showlist&id=' + id

parent.main.location.href(text)

}

function checkframe() {

if (window.top != window.self) { window.top.location="http://www.corrado-database.nl"; }

}

function allprintpopup() {

window.open('', 'thepopup','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=600,height=400');
return true;
}

function echeck(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 FillCombo(data)
{


	for (var i = document.applyupdate.subcategory.length ; i > 0 ; i--)
   	document.applyupdate.subcategory.options[0] = null;
	for(var i = 0; i < data.length ; i+=2)
	{

     var optionName = new Option(data[i+1], data[i], false, false);
     var length = document.applyupdate.subcategory.length;
     document.applyupdate.subcategory.options[length] = optionName;

	}

	if(navigator.userAgent.indexOf('Mac') == -1) 
		document.applyupdate.subcategory.selectedIndex = -1;
	else 
		document.applyupdate.subcategory.options[0].selected = true;	
	
}


function FillsubCombo(data,subid_selected)
{

       var subid = subid_selected;


	for (var i = document.applyupdate.subcategory.length ; i > 0 ; i--)
   	document.applyupdate.subcategory.options[0] = null;
	for(var i = 0; i < data.length ; i+=2)
	{

     var optionName = new Option(data[i+1], data[i], false, false);
     var length = document.applyupdate.subcategory.length;
     document.applyupdate.subcategory.options[length] = optionName; 

	}


	if(navigator.userAgent.indexOf('Mac') == -1) 
		document.applyupdate.subcategory.selectedIndex = -1;
	else 
		document.applyupdate.subcategory.options[0].selected = true;	


//	alert(selected);
     document.applyupdate.subcategory.options[subid_selected].selected=true;	
}



function ganaar(adres) { 
   window.location= adres; 
}	


function make_gray() {

	if(document.edit_c.kleurcode.value == "95") {

		document.edit_c.kleurcode_anders.style.visibility = "visible";

	} else {

		document.edit_c.kleurcode_anders.style.visibility = "hidden";

	}

}

function copy_clip(meintext)
{

 if (window.clipboardData) 
   {
   
   // the IE-manier
   window.clipboardData.setData("Text", meintext);
   
   // waarschijnlijk niet de beste manier om Moz/NS te detecteren;
   // het is mij echter onbekend vanaf welke versie dit precies werkt:
   }
   else if (window.netscape) 
   { 
   
   // dit is belangrijk maar staat nergens duidelijk vermeld:
   // you have to sign the code to enable this, or see notes below 
   netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
   
   // maak een interface naar het clipboard
   var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
   if (!clip) return;
   
   // maak een transferable
   var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
   if (!trans) return;
   
   // specificeer wat voor soort data we op willen halen; text in dit geval
   trans.addDataFlavor('text/unicode');
   
   // om de data uit de transferable te halen hebben we 2 nieuwe objecten nodig   om het in op te slaan
   var str = new Object();
   var len = new Object();
   
   var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
   
   var copytext=meintext;
   
   str.data=copytext;
   
   trans.setTransferData("text/unicode",str,copytext.length*2);
   
   var clipid=Components.interfaces.nsIClipboard;
   
   if (!clip) return false;
   
   clip.setData(trans,null,clipid.kGlobalClipboard);
   
   }
   alert("URL gekopieerd naar kopieer/plak tekst, om te linken naar een forum etc.\n\n" + meintext);
   return false;
}

var state = 'none';


function AntiSpam (domain,name) {
   location.href="mailto:" + name + "@" + domain;
   return true;
}


function changeContent(id,shtml) {
   if (document.getElementById || document.all) {
      var el = document.getElementById? document.getElementById(id): document.all[id];
      if (el && typeof el.innerHTML != "undefined") el.innerHTML = shtml;
   }
}

function editreply(message_id,type,ref_id,mode) {

	if(type=='edit') {

		window.open('reply.php?type=edit&id=' + message_id, 'edit_message_' + message_id , 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=630,height=430');

	}

	if(type=='new') {

		window.open('reply.php?type=new&mode=' + mode + '&ref_id=' + ref_id, 'new_message_' + ref_id , 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=630,height=430');

	}

}

function dbreply(nickname_DB,file,uid,rid,lang_front_from,prov,datum,tijd,edit_right,icon,message,cacheserver) {

 document.write('<table width=100% bgcolor=EEEEEE cellspacing=0 cellpadding=0><tr><td><table width=100% border=0><tr><td><b>'+ nickname_DB + '</b></td><td><font size=1><b><a href=' +file+ '?item=view_user&id=' +uid+ ' id=\"' +rid+ '\"><font size=1>' +nickname_DB+ '</font></a> ' + lang_front_from + ' ' +prov+ ' | ' +datum+ ' @ ' +tijd+ '</b></font>');
	
 if(edit_right=="yes") { document.write(' <a href=\"javascript:return false;\" ONCLICK=\"editreply(' + rid + ')\"><img src=\"int/edit.gif\" border=0></a>'); }

 document.write('<br><img src=int/x.gif height=1 width=530></td></tr><tr><td><img src=int/x.gif height=1 width=100><br>');

 if(icon!="") { document.write('<img src=\"' + cacheserver + '/usericon/' + icon + '.jpg\" border=1>'); } 

 document.write('</td><td valign=top><br><div style=\"width:530px;overflow:hidden;\"><span style=\"font-size:12px\">' +message+ '</span></div></td></tr></table></td></tr><tr><td height=1 bgcolor=#0000></td></tr></table>');

}

function open_showcase_pic(id,sc_id) {

	window.open('show_sc_pic.php?id=' + id + '&sc_id='+ sc_id, 'view_sc_' +id , 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=870,height=755');

}

function open_media(media_id,uid,cid) {

	window.open('show_media.php?media_id=' + media_id + '&uid='+ uid +'&cid='+ cid, 'view_media_' +media_id , 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=870,height=755');

}

function open_ubb(id) {

	window.open('ubb.php?start_tag=0&end_tag=0&sc_id=' + id, 'ubb_' +id , 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=370,height=400');

}

function open_high_quality(server,id,mode) {

	if(mode=='md') {

		window.open(server + '/showcase_' + mode + '/' + id + '.jpg', 'sc_image_' +id , 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=820,height=620');


	}

	if(mode=='hd') {

		window.open(server + '/showcase_' + mode + '/' + id + '.jpg', 'sc_image_' +id , 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=1044,height=788');

	}

	
}



function loadimage(id,desc) {

	var imagediv=document.getElementById('sc_image');
	imagediv.innerHTML = '<img border=1 src=\"' + cacheserver + '/showcase/' + id + '.jpg\" />';


}


function showcase_preload(id) {

//var preload_showcase_id = eval("sc"+ id);
var i = 0;

	for (x in showcase_id)	{

	var preload_image = 'sc_img.php?id=' + showcase_id[x];


        preload_showcase_id[i] = document.createElement('img');
        preload_showcase_id[i].setAttribute('src',preload_image);

	i++;

	}

}


var Timer;

function ScrollLeft()
{

  Timer = setInterval("document.getElementById('photoscroller').scrollLeft -= 5", 15);
}

function ScrollRight()
{

  Timer = setInterval("document.getElementById('photoscroller').scrollLeft += 5", 15);
}


function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

function opencountry(country_id){

	var divid = "provlist_"+ country_id;

	if(document.getElementById(divid).style.display == 'none'){
		document.getElementById(divid).style.display = 'block';
	}else{
		document.getElementById(divid).style.display = 'none';
	}

	get_region_list(country_id);

}


//////////////////////////////////////////////////////////////////////////////////
//
// AJAX functie's
//


function get_corrado_list(url) {
        var httpRequest;

        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            httpRequest = new XMLHttpRequest();
            if (httpRequest.overrideMimeType) {
                httpRequest.overrideMimeType('text/xml');
                // See note below about this line
            }
        } 
        else if (window.ActiveXObject) { // IE
            try {
                httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
                } 
                catch (e) {
                           try {
                                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                               } 
                             catch (e) {}
                          }
                                       }

        if (!httpRequest) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        httpRequest.onreadystatechange = function() { write_corrado_list(httpRequest); };
        httpRequest.open('GET', url, true);
        httpRequest.send(null);

}


function write_corrado_list(httpRequest) {

        if (httpRequest.readyState == 4) {
            if (httpRequest.status == 200) {
                //alert(httpRequest.responseText);

		var testhtml = httpRequest.responseText;

	var corradolistdiv=document.getElementById('corradolist');
	corradolistdiv.innerHTML = testhtml; //httpRequest.responseText;

            } else {
                alert('Error, could not retrieve the Corrado list, try again later...');
            }
        }

}

function get_region_list(country_id) {
        var httpRequest;
	var url = 'ajaxdb.php?type=getregionlist&country_id='+country_id;

        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            httpRequest = new XMLHttpRequest();
            if (httpRequest.overrideMimeType) {
                httpRequest.overrideMimeType('text/xml');
                // See note below about this line
            }
        } 
        else if (window.ActiveXObject) { // IE
            try {
                httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
                } 
                catch (e) {
                           try {
                                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                               } 
                             catch (e) {}
                          }
                                       }

        if (!httpRequest) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        httpRequest.onreadystatechange = function() { write_region_list(httpRequest,country_id); };
        httpRequest.open('GET', url, true);
        httpRequest.send(null);

}

function write_region_list(httpRequest,country_id) {

        if (httpRequest.readyState == 4) {
            if (httpRequest.status == 200) {
                //alert(httpRequest.responseText);

		var testhtml = httpRequest.responseText;

	var corradolistdiv=document.getElementById('provlist_'+country_id);
	corradolistdiv.innerHTML = testhtml; //httpRequest.responseText;

            } else {
                alert('Error, could not retrieve the region list, try again later...');
            }
        }


}

function get_reply_list(id,mode) {

	if(mode=='car') {

		get_ajax_data(id +'/car','getreplylist','replylist')

	} else {

		get_ajax_data(id +'/media','getreplylist','replylist')


	}

}

function load_media_profile(media_id, position, mode) {

	get_ajax_data(media_id + '/' + position + '/' + mode,'load_showcase_media_profile','div_pic_'+ position);

}

function choose_media_profile(corrado_id, position) {

	get_ajax_data(corrado_id + '/' + position,'choose_showcase_media','div_pic_'+ position);

}

function remove_media_profile(position) {

	var element = 'div_pic_'+ position;
	document.getElementById(element).innerHTML = '';

}

function load_showcase_list(showcase_id,position) {

	get_ajax_data(showcase_id + '/' + position,'choose_showcase_media_items','showcase_scroller_'+ position);
	get_ajax_data(showcase_id + '/' + position,'show_showcase_media_prop','showcase_edit_bar_'+ position);

}

function edit_showcase_name(showcase_id,position) {

	get_ajax_data(showcase_id + '/' + position,'load_showcase_name_edit','edit_showcase_name_'+ position);

}

function save_showcase_name(showcase_id,position) {

	var namedata = document.getElementById('showcase_nameinput').value;
	get_ajax_data(showcase_id + '/' + namedata +'/' + position,'save_showcase_name_edit','edit_showcase_name_'+ position);

}

function update_after_save_nameshowcase(id,position) {

get_ajax_data(id + '/'+ position,'choose_showcase_media_items','showcase_scroller_'+ position);
get_ajax_data(id + '/'+ position,'show_showcase_media_prop','showcase_edit_bar_' + position);


}

function load_media(media_id) {

	get_ajax_data(media_id,'showcasemedia','media_container');
	get_ajax_data(media_id,'showcasetags','tag_container');
	get_reply_list(media_id + '/0','media')

}

     function makeXmlHttp(){
          var xmlhttp = null;
          if(window.XMLHttpRequest){
          xmlhttp = new XMLHttpRequest();
          }else{
               try{
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
               }catch(e){
                    window.alert("Uw browser ondersteunt het XMLHttpRequest object niet!");
               }
          }
          
          return xmlhttp;
     }

function add_showcase_tag(media_id) { 

	get_ajax_data(document.tagform.addnewtag.value + '/' + media_id,'addnewtag','tag_container');


} 

function edit_tag(tag_id,media_id) {

	var element = 'tag_' +tag_id;
	get_ajax_data(tag_id,'load_edit_tag',element);

}

function add_new_item_sc(id,position) {

	get_ajax_data(id + '/' + position,'upload_formframe','showcase_scroller_'+ position);

}

function save_tag(tag_id, media_id) {

	tagdata = document.edit_form.elements['new_tag_' + tag_id];
	get_ajax_data(tag_id + '/' + tagdata.value,'update_tag','tag_container');

}

function delete_tag(tag_id,media_id) {

	get_ajax_data(tag_id,'delete_tag','tag_container');

}

function get_ajax_data(id,type,element) {



	//document.getElementById(element).innerHTML = '<img src="gfx/interface/loading.gif" alt="Loading" border="0" />';



	var xmlhttp = makeXmlHttp();
	xmlhttp.open("GET","../ajaxdb.php?type="+ type +"&id=" + id + "&t" +Math.random(),true)

			   xmlhttp.onreadystatechange = function() {

               if(xmlhttp.readyState == 4){
                    document.getElementById(element).innerHTML = xmlhttp.responseText;
               }
          }
		  	xmlhttp.send(null);
	 
}

function startUpload(){
	document.getElementById('f1_upload_process').style.visibility = 'visible';
	return true;
}

	function stopUpload(success){
	
	var result = '';
	
	if (success == 1){
	
      document.getElementById('result').innerHTML = '<span class="msg">The file was uploaded successfully!<\/span><br/><br/>';
	}
	 else {
	document.getElementById('result').innerHTML ='<span class="emsg">There was an error during file upload!<\/span><br/><br/>';
	}
	document.getElementById('f1_upload_process').style.visibility = 'hidden';
	 return true;
}