﻿/********************************************
 *
 * Javascripts for mobile & openhouse site redirection
 *
 ********************************************/

	// Build an empty URL structure in which we will store
	// the individual query values by key.
	var objURL = new Object();


	// Use the String::replace method to iterate over each
	// name-value pair in the query string. Location.search
	// gives us the query string (if it exists).
	window.location.search.replace(
		new RegExp( "([^?=&]+)(=([^&]*))?", "g" ),

		// For each matched query string pair, add that
		// pair to the URL struct using the pre-equals
		// value as the key.
		function( $0, $1, $2, $3 ){
			objURL[ $1 ] = $3;
		}
		);
 
var skip = "false";
//var skip = "true";

for (var strKey in objURL){
	if(strKey+"="+objURL[ strKey ]=="mobile=false"){
		skip = "true";
	}
	if(strKey+"="+objURL[ strKey ]=="main=false"){
		skip = "true";
	}
}

if(skip!="true"){
        
        if((navigator.userAgent.match(/iPhone/i))||
        (navigator.userAgent.match(/iPod/i))||
		(navigator.userAgent.match(/iPad/i))||
		(navigator.userAgent.indexOf("iPad") != -1)||
		(navigator.platform.indexOf("iPad") != -1)||
		(navigator.userAgent.match(/iPad/i) != null)||
        (navigator.userAgent.match(/samsung/i))||
        (navigator.userAgent.match(/sony/i))||
        (navigator.userAgent.match(/moto/i))||
        (navigator.userAgent.match(/wap/i))||
        (navigator.userAgent.match(/j2me/i))||
        (navigator.userAgent.match(/Windows phone/i))||
        (navigator.userAgent.match(/Symbian/i))||
        (navigator.userAgent.match(/blackberry/i))||
        (navigator.userAgent.match(/palm/i))||
        (navigator.userAgent.match(/HTC/i))||
        (navigator.appVersion.indexOf("Windows CE")>0)||
        (navigator.userAgent.match(/webOS/i))||
        (navigator.userAgent.match(/Android/i))||
		(navigator.userAgent.match(/mobile/i)))
        {
        location.replace("/mobile");
        }
		//else
		//{
		//location.replace("/jae/documents/index.html");
		//}
}

