﻿/*
 * WiredText
 * http://www.WiredText.com
 * 
 * Copyright (c) 2009 WIREDTEXT INC.
 *
 * Date: 2009-01-01 
 * Revision: 02.00.00
 *
 * Requires jQuery version 1.3.1+
 */
 
 
 //Image Rollovers
function wt_setRolloverImages(){
	$("img.rollover").hover(
	    function(){
	this.src = this.src.replace(".jpg", "_over.jpg");
	this.src = this.src.replace(".gif", "_over.gif");
		 },
		 function(){
		 this.src = this.src.replace("_over.jpg", ".jpg");
		 this.src = this.src.replace("_over.gif", ".gif");
		 }
	);
}

    
$(function() {
    wt_setRolloverImages();
})


///<summary>
///to see if the phone value of the textfield is a valid format
///</summary>       
function isGoodPhone(args) {
    var numericExpression1 = /^[0-9{\d-}{\d.}{\d(}{\d)} ]+$/;

    if (!args.value.match(numericExpression1) && args.value !== '') {
        alert('Incorrect Phone Number Format');
        setValue(args);
        args.focus();
    }
    return true;
}

function isAlphaNumeric(args, valClientID) {

    var element = args.value;


    if (!args.value.match(numericExpression1)) {

        //alert('Incorrect VIN / HIN Format \n Only letters, numbers and dashes are allowed');
        args.value = "";
        document.getElementById(valClientID).style.display = "block";
        document.getElementById(valClientID).innerText = "Please enter your VIN / HIN number";

    }


    return;
}


///<summary>
///Check if the value of the passed textField contains non-numbers
///</summary>       
function numberTest(args, msg) {

    var numericExpression = /^[0-9]+$/;

    if (!args.value.match(numericExpression) || args.value == '') {
        if (msg != null) {
            window.alert(msg);
        }
        return false;
    }
    return true;

}


///<summary>
///This will remove the google stylesheet crap of yellowing the input fields
///</summary>     
function removeGoogleAutoFormat() {
    if (window.attachEvent)
        window.attachEvent("onload", setListeners);

    function setListeners() {
        inputList = document.getElementsByTagName("INPUT");
        for (i = 0; i < inputList.length; i++) {
            inputList[i].attachEvent("onpropertychange", restoreStyles);
            inputList[i].style.backgroundColor = "";
        }
        selectList = document.getElementsByTagName("SELECT");
        for (i = 0; i < selectList.length; i++) {
            selectList[i].attachEvent("onpropertychange", restoreStyles);
            selectList[i].style.backgroundColor = "";
        }
    }

    function restoreStyles() {
        if (event.srcElement.style.backgroundColor != "")
            event.srcElement.style.backgroundColor = "";
    } //-->

}

///<summary>
///Something to do if its firefox
///useful when doing stylesheet shifting etc...
///</summary>  
function browserCheck() {
    if (navigator.userAgent.indexOf("Firefox") != -1) {
        var versionindex = navigator.userAgent.indexOf("Firefox") + 8
    }
    if (parseInt(navigator.userAgent.charAt(versionindex)) >= 1) {
        //firefox specific code here
    }
}


///<summary>
///check to see if the passsed string is valid e-mail or not
///</summary>  
///<param value="str">string to check if valid e-mail</param>
function isValidEmail(str) {
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}
  
     


