//
// iBetaTest.com Global UI JavaScripts
// by Petar Smilajkov - Peconi
// http://peconi.com | http://smilajkov.com/petar
//

var webDataPath = 'http://www.ibetatest.com/iphone/data/';
var webThemePath = 'http://www.ibetatest.com/iphone/themes/iphone/';

function alertPeeps(){
	alert('Coming up shortly!\nRegister and be the first to know when it\'s available!');
}

function signUp(){
	$('tempArea').innerHTML = 'Howdy!';
	return false;
}

function sneakPeak(){
	alertPeeps();
}

function getEventTarget(e){
	e = e || window.event;
	return e.target || e.srcElement;
}

function isUrl(s) {
	 var regexp = /^((http|https):?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/; 
	return regexp.test(s);
}

function isEmail(s) {
	 var regexp = /^((([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|\/|=|\?|\^|_|`|\{|\||\}|~)+(\.([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|\/|=|\?|\^|_|`|\{|\||\}|~)+)*)@((((([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.))*([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.)[\w]{2,4}|(((([0-9]){1,3}\.){3}([0-9]){1,3}))|(\[((([0-9]){1,3}\.){3}([0-9]){1,3})\])))$/ 
     return regexp.test(s);
}

function var_dump(obj) {
   if(typeof obj == "object") {
      return "Type: "+typeof(obj)+((obj.constructor) ? "\nConstructor: "+obj.constructor : "")+"\nValue: " + obj;
   } else {
      return "Type: "+typeof(obj)+"\nValue: "+obj;
   }
}//end function var_dump

function mainmenu(){
$(" #nav ul ").css({display: "none"}); // Opera Fix
$(" #nav li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(400);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}

// on DOM ready, let the magic begin
$(document).ready(function(){
	mainmenu();
	
	// fade out success messagess
	setTimeout(function(){
			$('#messages').fadeOut(2000);
		},4000
	); 
    
	var previousIcon = "";
	// TODO: dynamically change icon when mousing over global menu
	$("[id*=globals-]").mouseover(function(){
		
	});
	$("[id*=globals-]").mouseout(function(){
		
	});
    
    Array.prototype.inArray = function (value,caseSensitive)
    // Returns true if the passed value is found in the
    // array. Returns false if it is not.
    {
    var i;
    for (i=0; i < this.length; i++) {
    // use === to check for Matches. ie., identical (===),
    if(caseSensitive){ //performs match even the string is case sensitive
    if (this[i].toLowerCase() == value.toLowerCase()) {
    return true;
    }
    }else{
    if (this[i] == value) {
    return true;
    }
    }
    }
    return false;
    };
    
    // apply to all png images 
	$('img[@src$=.png]').ifixpng(); 
    
}); // end DOM ready
