// JavaScript Document

/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}


// modified link to get title and href <a href="javascript:bookmarksite(document.title, location.href)">Bookmark this site!</a>

// Email Page Link

function mailpage()
{
mail_str = "mailto:?subject= Check this link --> " + document.title;
mail_str += "&body= " + document.title;
mail_str += "... at: " + location.href;
location.href = mail_str;
} 

// Email Page Link

function mailpage_video()
{
mail_str = "mailto:?subject= Check out this video about itegrity from REDW --> " + document.title;
mail_str += "&body= " + document.title;
mail_str += "... at: " + location.href;
location.href = mail_str;
} 

// <a href="javascript:mailpage()" target="_top">Send this link to a friend</a>

/*******************************************************************
* JavaScript/CSS Font Size Changer (Persistent Between Pages)
* (c) DB Design, All rights are reserved
* http://phpscriptindex.com, phpsales@gmail.com
********************************************************************
* Script will allow user to visually change font size. Font size 
* will persist thru page change using a cookie.
********************************************************************
* Directions: Change fontElementId var to the element id you wish to
* allow users to change font sizes. 
********************************************************************
* Tip: Next span element inside normal div to inherit parent style
* but enable use to change font size.
*******************************************************************
* FireFox 2.0.0.3 Tested
* MS IE 7 Tested
* Netscape 8.1.2 Tested
* Opera 9.1 Tested
******************************************************************/

var fontElementId = "page_content"; //CHANGE ME TO YOUR ELEMENT ID

//DO NOT MODIFY BELOW

/* Module Change Font (string) */
function changeFont(fontClass){
	var element = document.getElementById(fontElementId);
	element.className = fontClass;
	setCookie("fontSize", fontClass, 5);
}		

/* Module Set Default Font Size (void) */
function setDefaultFontSize(){
	var fontSize = getCookie("fontSize")
	if(fontSize){
		var element = document.getElementById(fontElementId);
		element.className = fontSize;
	}
}

/* Module Set Cookie (string, string, int) -- http://www.w3schools.com/js/js_cookies.asp */
function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
/* Module Get Cookie (string) -- http://www.w3schools.com/js/js_cookies.asp */
function getCookie(c_name){
	if(document.cookie.length>0){
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1){ 
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return false;
}


/************* Facebox Contact Verification *************/
// Facebox
function FaceBoxVerifyContactForm() {
	jQuery.facebox({ ajax: 'contact_disclaimer.php?Page=contact_disclaimer' });
	
	//alert ('here you go');
}

// Facebox
function FaceboxContactConfirmation(is_approved) {	
	
	if (is_approved && document.ConfirmForm.agree.checked) {
		jQuery(document).trigger('close.facebox');
		setTimeout("document.ContactForm.submit ()",1000);	
	} else if (is_approved && !document.ConfirmForm.agree.checked){
		alert ('please check the confirmation box before continuting');
		return;
	} else if (!is_approved) {
		jQuery(document).trigger('close.facebox');
	} 
}



/************* Mobile Detection and Support *************/

function is_mobile_browser() {

	var agent = navigator.userAgent.toLowerCase();
	var scrWidth = screen.width;
	var scrHeight = screen.height;

	// The document.documentElement dimensions seem to be identical to
	// the screen dimensions on all the mobile browsers I've tested so far
	var elemWidth = document.documentElement.clientWidth;
	var elemHeight = document.documentElement.clientHeight;

	// We need to eliminate Symbian, Series 60, Windows Mobile and Blackberry
	// browsers for this quick and dirty check. This can be done with the user agent.
	var otherBrowser = (agent.indexOf("series60") != -1) || (agent.indexOf("symbian") != -1) || (agent.indexOf("windows ce") != -1) || (agent.indexOf("blackberry") != -1);

	// If the screen orientation is defined we are in a modern mobile OS
	var mobileOS = typeof orientation != 'undefined' ? true : false;

	// If touch events are defined we are in a modern touch screen OS
	var touchOS = ('ontouchstart' in document.documentElement) ? true : false;
	
	// iPhone and iPad can be reliably identified with the navigator.platform
	// string, which is currently only available on these devices.
	var iOS = (navigator.platform.indexOf("iPhone") != -1) ||
        (navigator.platform.indexOf("iPad") != -1) ? true : false;
 
	// If the user agent string contains "android" then it's Android. If it
	// doesn't but it's not another browser, not an iOS device and we're in
	// a mobile and touch OS then we can be 99% certain that it's Android.
	var android = (agent.indexOf("android") != -1) || (!iOS && !otherBrowser && touchOS && mobileOS) ? true : false;
		
	// return true if mobile device
	if (otherBrowser  || mobileOS  || touchOS  || iOS  || android) {
		return true;
	} else {
		return false;
	}
}


function output_mobile_css() {
	
	// mobile css output
	if (is_mobile_browser()) {
		//alert ('mobile stuff');
		document.getElementById("tablet").style.display = 'block';
		document.getElementById("desktop").style.display = 'none';
	} else {
		//alert ('regular stuff');
		//document.getElementById("tablet").style.display = 'none';
		//document.getElementById("desktop").style.display = 'block';
		doc.write('     <style> \
		.tablet { display:block !important; } \
		.desktop { display:none !important; } \
		</style>');
	}
}
