//  Created By LDR STUDIOS
//  Copyright 2009  Michael Noël  All Rights Reserved
//  LDR is @ www.ldrstudios.com/

/////////////////////////////////////////////////////////////////////////////////////////////////

function di(id,name){
	if (document.images) document.images[id].src=eval(name+".src"); 
}

function getWinDim() {
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winW = window.innerWidth;
			winH = window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
		}
	}
	
	return [winH,winW];
}	

/////////////////////////////////////////////////

function checkWidth(obj) {
	var thisObj = document.getElementById(obj);
	var currentDim = getWinDim();
	var currentW = currentDim[1];
	
	thisObj.style.width = (currentW) + 'px';
}

/////////////////////////////////////////////////

function checkHeight(obj) {
	var thisObj = document.getElementById(obj);
	var currentDim = getWinDim();
	var currentH = currentDim[0];
	
	thisObj.style.height = (currentH-40) + 'px';
}

function gotoPage(page) {
	document.location.href=page;
}
	
/////////////////////////////////////////////////////////////////////////////////////////////////

function addslashes(str) {
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\0/g,'\\0');
	return str;
}
function stripslashes(str) {
	str=str.replace(/\\'/g,'\'');
	str=str.replace(/\\"/g,'"');
	str=str.replace(/\\\\/g,'\\');
	str=str.replace(/\\0/g,'\0');
	return str;
}
	
/////////////////////////////////////////////////////////////////////////////////////////////////

function showHide(obj_hide,obj_show) { //onclick either shows or hides the current dropout
	//hideAll();
	var hide_me = document.getElementById(obj_hide);
	var show_me = document.getElementById(obj_show);
	
	//alert(shower.style.display);
	
	show_me.style.display = "block";
	hide_me.style.display = "none";
}

function confirmMessageRemoval(pid) {
	var agree=confirm("Delete message? (this is permanent)");
	if (agree) document.location.href = "message-process.php?type=remove&pmid=" + pid; //expandtab('message_'+pid, 3); //Effect.Fade('message_'+pid);
	//else expandtab('message_'+pid, 0);
}

function messageRemoval(pid) {
	Effect.Fade('message_'+pid);
	//else expandtab('message_'+pid, 0);
}

/////////////////////////////////////////////////////////////////////////////////////////////////

function searchSubmit(defaultval,searchLocation,type) {			
	if(type == 'main') var term = document.getElementById('mainsearchterm').value;
	else var term = document.getElementById('searchterm').value;
	if(term != '' && term != ' ' && term != defaultval) {
		newterm = term.replace(/ /g,"-");
		newterm = newterm.replace(/\"/g,"");
		newterm = newterm.replace(/\'/g,"");
		if(document.getElementById('stype')) {
			if(!document.getElementById('stype').checked) document.location.href = '/search/'+newterm;
			else document.location.href = searchLocation+''+newterm;
		} else document.location.href = searchLocation+''+newterm;
		return (false);
		
	} else {
		alert('You have not entered a search term');
		return (false);
	}
}

//////////////////////////////////////////////////////////////////////////////////////////////////

// Show Contact Info
function showcontact() {
	var contact = document.getElementById('contactrow');
	var client_list = document.getElementById('clientlistrow');
	client_list.style.display = "none";
	if(contact.style.display == "block") contact.style.display = "none";
	else contact.style.display = "block";
	
	//window.scrollBy(0, window.innerHeight ? window.innerHeight : document.body.clientHeight);
	window.scrollBy(0,10000);
}	

// Show Pricay Window
function showclientlist() {
	var contact = document.getElementById('contactrow');
	var client_list = document.getElementById('clientlistrow');
	contact.style.display = "none";
	if(client_list.style.display == "block") client_list.style.display = "none";
	else client_list.style.display = "block";
	
	window.scrollBy(0, window.innerHeight ? window.innerHeight : document.body.clientHeight);
}

/////////////////////////////////////////////////////////////////////////////////////////////////

function SendContact() {
	contactXMLHttpObj = getXMLHttpRequestObject();
	// open socket connection
	contactXMLHttpObj.open("POST","viper/themes/ldrstudios/includes/contact-process.php",true);

	var name = document.getElementById('contactname').value;
	var email = document.getElementById('contactemail').value;
	var message = document.getElementById('contactmessage').value;

	// set form http header
	contactXMLHttpObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	contactXMLHttpObj.send("name=" + name + "&email=" + email + "&message=" + message);
	contactXMLHttpObj.onreadystatechange = contactStatusChecker;	

	return false;
}

/////////////////////////////////////////////////////////////////////////////////////////////////

function contactStatusChecker() {
    // check if request is completed
    if(contactXMLHttpObj.readyState == 4) {
        if(contactXMLHttpObj.status == 200) updateContactInline(contactXMLHttpObj);
    }
}

/////////////////////////////////////////////////////////////////////////////////////////////////

function updateContactInline(reqObj) {
	var response = reqObj.responseText;
	
	if(response == 'pass') var text = "<strong>Message sent successfully.</strong>";
	else var text = "There was an issue sending your message. Please try again.";
	
	var container = document.getElementById('contactrow');
	headHTML = '<table cellpadding="0" cellspacing="0" border="0" width="840"><tr><td width="144">&nbsp;</td><td valign="top" style="width:485px;">';
	footHTML = '</td><td width="130">&nbsp;</td></tr></table>';
	container.innerHTML = headHTML + text + footHTML;
	
	//setTimeout("Effect.Fade('contactrow');",1000);	
}

/////////////////////////////////////////////////////////////////////////////////////////////////

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();


/////////////////////////////////////////////////////////////////////////////////////////////////




/////////////////////////////////////////////////////////////////////////////////////////////////





/////////////////////////////////////////////////////////////////////////////////////////////////





/////////////////////////////////////////////////////////////////////////////////////////////////





/////////////////////////////////////////////////////////////////////////////////////////////////
